m = int(input())
costs = list(map(int, input().split()))

n, e = map(int, input().split())

ans = [0]*n
belt = [0] * (n+1)

chef_time = 0
chef_ind = 0

for _ in range(e):
    t, x = map(int, input().split())
    while chef_time < t:
        if not belt[(-chef_time)%(n+1)]:
            belt[(-chef_time)%(n+1)] = costs[chef_ind%m]
            chef_ind += 1
        chef_time += 1
    ans[x-1] += belt[(x-t)%(n+1)]
    belt[(x-t)%(n+1)] = 0

print(*ans,sep='\n')
