n=int(input())
zarada1=input().split()
zarada=[]
for i in range(n):
    zarada.append(int(zarada1[i]))
pref=[0]
for i in range(n):
    pref.append(pref[i]+zarada[i])
m=int(input())
for i in range(m):
    a,b=input().split()
    a=int(a)
    b=int(b)
    print(pref[b+1]-pref[a])
