#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int n; int a[100000]; long long dp[50][100000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; REP (i, n) cin >> a[i]; REP (i, n) dp[0][i] = a[i]; for (int j = 1; j < 50; j++) { for (int i = 0; i < n; i++) dp[j][i] = dp[j-1][i] + dp[j-1][(i + dp[j-1][i]) % n]; // i: current state of x, j: log(length) } int q; cin >> q; REP (_, q) { long long k; cin >> k; long long x = 0; REP (i, 50) { if (k & 1LL<