#include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; } fio; signed main(){ cout< A; vector> table, table2; cin>>N; A.resize(N); table.resize(45, vector(N)); table2.resize(45, vector(N)); for(int i = 0; i < N; i++){ cin>>A[i]; table[0][i] = (A[i] + i)% N; table2[0][i] = A[i]; } for(int i = 1; i < table.size(); i++){ for(int j = 0; j < N; j++){ table[i][j] = table[i-1][table[i-1][j]]; table2[i][j] = table2[i-1][table[i-1][j]] + table2[i-1][j]; } } cin>>Q; for(int i = 0; i < Q; i++){ int K; int res = 0, now = 0; cin>>K; for(int i = 0; i < table.size(); i++){ if((K>>i)&1) { res += table2[i][now]; now = table[i][now]; } } cout<