#include using namespace std; using ll=long long; using vin=vector; using vll=vector; using vvin=vector>; using vvll=vector>; using vstr=vector; using vvstr=vector>; using vch=vector; using vvch=vector>; using vbo=vector; using vvbo=vector>; using vpii=vector>; using pqsin=priority_queue,greater>; #define mp make_pair #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,s,n) for(int i=(s);i<(int)(n);i++) #define all(v) v.begin(),v.end() #define decp(n) cout<>n; vll a(n);rep(i,n)cin>>a[i]; set r; vll x;x.push_back(0); ll tmp;ll sum=0; while(1){ tmp=sum%n; if(r.count(tmp))break; r.insert(tmp); sum+=a[tmp]; x.push_back(sum); } ll s=x.size();ll num; rep(i,s)if(x[i]%n==tmp){ num=i; break; } s--; //cout<>q; ll k;vll ans(q); rep(i,q){ cin>>k; if(k<=num)ans[i]=x[k]; else ans[i]=x[num]+((k-num)/(s-num))*(x[s]-x[num])+x[num+k%(s-num)]-x[num]; } rep(i,q)cout<