import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) A=[int(i) for i in input().split()] x=0 C=[False]*n C[0]=True import collections D=collections.defaultdict(int) Ans=[] ct=1 while True: Ans.append(x) if D[x%n]!=0: st=D[x%n] ed=ct Ans.append(x+A[x%n]) break else: D[x%n]=ct ct+=1 x+=A[x%n] q=int(input()) for _ in range(q): k=int(input()) if k<=ed: print(Ans[k]) else: ans=Ans[st] loop=(k-st)//(ed-st) ans+=loop*(Ans[ed]-Ans[st]) rem=(k-st)%(ed-st) ans+=Ans[st+rem]-Ans[st] print(ans)