n = int(input()) a = list(map(int,input().split())) q = int(input()) used = set() x = 0 ans = [] x_ans = [0] while True: tar = x % n x += a[tar] if tar not in used: used.add(tar) ans.append(tar) x_ans.append(x) else: t = tar break ind_t = ans.index(t) dif = x_ans[-1] - x_ans[ind_t] dif_array = x_ans[ind_t+1:] for i in range(len(dif_array)): dif_array[i] -= dif st = x_ans[ind_t] for i in range(q): k = int(input()) if k <= n: print(x_ans[k]) else: k -= ind_t loop = k//len(dif_array) mod = k % len(dif_array) print(st + loop*dif + sum(dif_array[:mod]))