#include using namespace std; using ll = long long; const ll D = 58; int main() { ll n; cin >> n; vector a(n); vector> ds(D, vector(n)); vector> su(D, vector(n)); for(ll i = 0; i < n; i++)cin >> a[i]; for(ll i = 0; i < n; i++) { ds[0][i] = (i + a[i]) % n; su[0][i] = a[i]; } for(ll i = 0; i < D - 1; i++) { for(ll j = 0; j < n; j++) { ds[i + 1][j] = ds[i][ds[i][j]]; su[i + 1][j] = su[i][j] + su[i][ds[i][j]]; } } ll m; cin >> m; vector q(m); for(ll i = 0; i < m; i++)cin >> q[i], q[i]--; for(ll i = 0; i < m; i++) { ll x = 0; ll ans = 0; for(ll j = 0; j < D; j++) { if(q[i] & (1LL<