An integer N is given on the first line, and N integers separated by single spaces are given on the second line. Integers L and R are given on the third line, separated by a single space.
Output, on one line, the sum of the elements from the L-th to the R-th (inclusive) in the sequence. Count the first element as the 1st.
For example, if the sequence is 1 2 3 4 5 and L=2, R=4, then 2 + 3 + 4 = 9, so output 9.
Constraints
1 ≤ N ≤ 100, 1 ≤ L ≤ R ≤ N, 0 ≤ each element ≤ 1000
Input example 1
5
1 2 3 4 5
2 4Output example 1
9Input example 2
3
10 20 30
1 3Output example 2
60What you'll train
Specify the input
What you get
How to ask the AI
Tell the AI that there are 3 lines of input, and that the third line specifies the range with L and R. It's also reassuring to specifically mention that the L-th and R-th positions are counted starting from 1, and that the sum includes both endpoints.
If you ask vaguelyThe AI may process indices starting from 0, causing the range from the L-th to the R-th element to be shifted by one from what's intended.
あなたのコード
プレビュー
AIレビュー(プロンプト練習)
コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。