import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() A=LI() Q=I() L=[0]*N#L[i]はX=iからの操作後の値 for i in range(N): X=i L[i]=(X + A[X%N]) M=45 dub=[[0]*N for _ in range(M)] for j in range(N): dub[0][j]=j dub[1][j]=L[j] for i in range(2,M): for j in range(N): a=dub[i-1][j]#一つ上 b=a%N jj=a%N diff=dub[i-1][jj]-jj dub[i][j]=a+diff # for i in range(3): # print(dub[i]) p=[1,1] for i in range(M+1): p.append(p[-1]*2) for _ in range(Q): K=I() ans=0 for i in range(M-1,-1,-1): if p[i] <= K: ans+=dub[i][ans%N] K-=p[i] print(ans) main()