from itertools import accumulate import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) A = list(map(int, input().split())) seen = [0] * N first = [0] second = [0] x = 0 while True: i = x % N if seen[i] == 0: first.append(A[i]) x += A[i] seen[i] = 1 elif seen[i] == 1: second.append(A[i]) x += A[i] seen[i] = 2 elif seen[i] >= 2: break F = list(accumulate(first)) S = list(accumulate(second)) LF = len(F) - 1 LS = len(S) - 1 def cnt(k): if k <= len(F): return F[k] res = F[LF] k -= LF d, m = divmod(k, LS) res += d * S[LS] res += S[m] return res Q = int(input()) for _ in range(Q): k = int(input()) print(cnt(k))