import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 10 ** 9 + 7 MOD = 998244353 INF = 10 ** 18 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] """ Main Code """ n = getN() a = getList() q = getN() query = [getN() for _ in [0] * q] def calc(db, now): next = [0] * n for i in range(n): next[i] = now[i] + db[(i + now[i]) % n] return next m = 50 db = [a[:] for _ in [0] * m] for i in range(m - 1): db[i + 1] = calc(db[i], db[i]) for t in query: ans = 0 for i in range(m): if(t & 1): ans += db[i][ans % n] t >>= 1 print(ans)