import sys

input = sys.stdin.readline

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split()))
    cum = [0] * (n + 1)

    for i in range(1, n + 1):
        cum[i] = cum[i - 1] + arr[i - 1]

    q = int(input())
    for _ in range(q):
        s, e = map(int, input().split())
        print(cum[e] - cum[s - 1])
