//Shirasu Azusa 2024.08 #include #define fi first #define se second #define eb emplace_back #define mp make_pair using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; template T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);} template T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);} template bool chmax(T &a,const S b) {return (a bool chmin(T &a,const S b) {return (a>b?a=b,1:0);} int popcnt(int x) {return __builtin_popcount(x);} int popcnt(ll x) {return __builtin_popcountll(x);} int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));} int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));} int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));} int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));} #define int long long #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) typedef pair pii; typedef vector vi; typedef vector vp; typedef tuple tiii; int read() { int x=0,w=1; char c=getchar(); while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();} while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} return x*w; } const int N=2e5+5; int n,a[N],q,ans[N],vst[N],b[N],m,t,l,sum,s[N]; signed main() { n=read(); rep(i,0,n-1) a[i]=read(); m=1; b[1]=0; vst[0]=1; for(int x=0;;) { x=(x+a[x])%n; if(vst[x]) {t=x; break;} else vst[x]=1, b[++m]=x; } rep(i,1,m) if(b[i]==t) {l=i; break;} rep(i,1,m) s[i]=s[i-1]+a[b[i]]; rep(i,l,m) sum+=a[b[i]]; int pp=(m-l+1); q=read(); rep(i,1,q) { int k=read(); if(k