# your code goes here
n=int(input())
a=list(map(int, input().split()))
p=[0]*n
p[0]=a[0]
for i in range(1, n):
    p[i]=p[i-1]+a[i]
Q=int(input())
for _ in range(Q):
    l, r=map(int, input().split())
    if l==0:
        total=p[r]
    else:
        total=p[r]-p[l-1]
    print(total)