시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 32 28 27 93.103%

## 문제

Suppose we have an array of integers such as 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. It is easy to compute the sum of all its elements. We only need a loop! For example:

int size = 10;
int total = 0;
for (int i = 0; i < size; i += 1) {
total = total + v[i];
}


If we want to count a different range of elements (for example, from position 5 to 7) we only need to change a few parts of the loop. In this problem you'll have to do this operation several times!

## 입력

The first line of the input will contain an integer n (the array size). The next line will contain n integers separated by spaces.

After the array, the next line will contain an integer m (the number of tests). The next m lines will contain a test each. A test is a pair of integers start, end. You'll have to compute the sum of the elements from the position start to end.

Limits

• n will be a number from 1 to 100000
• start and end will be valid positions of the array
• start <= end
• the values of the array will be integers from 0 to 9
• m will be at most 10000

## 출력

For each test, print the sum of the elements of the array from the position start to the position end inclusive.

That is: array[start] + array[start+1] + ... + array[end-1] + array[end].

## 예제 입력

10
1 5 6 3 5 9 0 3 9 1
5
1 1
0 9
5 7
9 9
1 8


## 예제 출력

5
42
12
1
40