N = int(input()) A = list(map(int, input().split())) Q = int(input()) querie = [int(input()) for i in range(Q)] mod_set = set([0]) seq = [0] now_value = 0 flag = True while flag: V = now_value + A[now_value % N] if not V % N in mod_set: mod_set.add(V % N) seq.append(V) now_value = V continue else: flag = False seq.append(V) L, R = 10**10, 0 modular = seq[-1] % N for i in range(len(seq)): if seq[i] % N == modular: R = i L = min(L, i) D = seq[R] - seq[L] period = R-L def solve(X): if X <= L: return seq[X] else: u, v = divmod(X- L, period) return seq[L+v] + D*u for q in querie: print(solve(q))