pref = [0]
_ = input()
for liczba in map(int, input().split()):
pref.append(pref[-1]+liczba)
print(pref)
test = int(input())
for i in range(test):
a,b = map(int, input().split())
print(pref[b]-pref[a-1])
cHJlZiA9IFswXQpfID0gaW5wdXQoKQpmb3IgbGljemJhIGluIG1hcChpbnQsIGlucHV0KCkuc3BsaXQoKSk6CglwcmVmLmFwcGVuZChwcmVmWy0xXStsaWN6YmEpCnByaW50KHByZWYpCnRlc3QgPSBpbnQoaW5wdXQoKSkKZm9yIGkgaW4gcmFuZ2UodGVzdCk6CglhLGIgPSBtYXAoaW50LCBpbnB1dCgpLnNwbGl0KCkpCglwcmludChwcmVmW2JdLXByZWZbYS0xXSkKCQ==