#include long long a[100005]; long long sum[100005]; int vis[100005]; int step[100005]; long long getSum(int r,int k,int n){ long long res = 0; for(int i = 0; i < k; i++){ res += a[r]; r = res%n; } return res; } int main(){ int n; scanf("%d",&n); for(int i = 0; i < n; i++) scanf("%lld",&a[i]); vis[0] = 1, step[0] = 0, sum[0] = 0; int u = 0; int cycle = -1, start = -1; long long weight = 0; while(true){ int v = (u+a[u])%n; //printf("u = %d v = %d\n",u,v); if(vis[v]==1){ cycle = step[u]+1-step[v]; start = v; weight = sum[u]+a[u]-sum[v]; break; } else{ vis[v] = 1; step[v] = step[u]+1; sum[v] = sum[u]+a[u]; u = v; } } //printf("start = %d, cycle = %d, weight = %lld\n",start,cycle,weight); int q; scanf("%d",&q); while(q--){ int k; scanf("%d",&k); if(k