As always, this time again, Suresh and Ramesh went to the tailor for shortening of their father's Pent. And guess what after a bite of Perk they went insane and got it shorten more then what was expected!

This time, Suresh's father wanted to punish him so that he will be busy for sometime, this way Suresh and Ramesh won't do anything wrong.

So he gave Suresh an array, A, of integers with N integers. And he will ask Q queries of form "L R", Suresh will have to calculate sum of array element from index L to R. And print it in a newline. Array is 1-based indexed.

Suresh want you to help in that.  

Input:

First line containing N, array size

Second line with N space-separated integers  A[1]  A[2] ....... A[N].

Third line with an integer Q, the number of queries.

Then Q lines with two integers  L R.

Output:

Print answer to each query in Q lines.

Constraints:

0 < L ≤ R< N ≤ 100001

0 < Q < 100001

-1001 < A[i] < 1001
Register for IndiaHacksSAMPLE INPUT
5
1 2 3 4 5
4
1 2
1 3
2 3
3 4

SAMPLE OUTPUT
3
6
5
7

Register for IndiaHacks
count = int(raw_input())
nos = raw_input().split(" ")

inos = []
sumArray = []
su = 0
for n in nos:
	inos.append(int(n))
	su += int(n)
	sumArray.append(su)

queryCount = int(raw_input())	

def queryOutput(l,r):
	l,r = int(l),int(r)
	return sumArray[r-1] - sumArray[l-1] + inos[l-1]

for query in range(1, queryCount + 1):
	l,r = raw_input().split(" ")
	print queryOutput(l,r)