# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n, = map(int,readline().split()) *a, = map(int,readline().split()) dist = [a[:]] nxt = [[(i+a[i])%n for i in range(n)]] #print(nxt) #print(dist) for _ in range(40): res = [dist[-1][nxt[-1][i]] + dist[-1][i] for i in range(n)] dist.append(res) res = [nxt[-1][nxt[-1][i]] for i in range(n)] nxt.append(res) #print(nxt[:2]) #print(dist[:2]) q,*k = map(int,read().split()) for ki in k: d = 0 x = 0 i = 0 for m in range(40,-1,-1): if i + (1<