N = int(input()) A = list(map(int, input().split())) Y = [] C = [0] B = [-1] * N x = 0 i = 0 r = 0 while B[r] == -1: B[r] = i Y.append(r) x += A[r] C.append(x) r = x % N i += 1 start = B[r] loop = i - B[r] if start == 0: loopsum = C[i] else: loopsum = C[i] - C[B[r]] for _ in range(int(input())): k = int(input()) if k <= i: print(C[k]) else: print(C[(k - start) % loop + start] + (k - start) // loop * loopsum)