#include <bits/stdc++.h>   using namespace std;   long long N, Q;   long long A[1100100], a, b;   vector<pair<long long, long long> > qu[1100100];   long long sol[1100100], dp[1100100];   long long solve(long long I, long long b) {     if (I > N) return 0;     long long ret = A[I];     return ret += solve(I + b, b);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> N;     for (long long I = 1; I <= N; I++) cin >> A[I];     cin >> Q;     for (long long q = 1; q <= Q; q++) {       cin >> a >> b;       qu[b].push_back(pair<long long, long long>(a, q));     }     for (long long b = 1; b <= N; b++) {       if (b < 300) {         for (long long I = N; I >= 1; I--) {           dp[I] = A[I];           if (I + b <= N) dp[I] += dp[I + b];         }         for (typeof((qu[b]).begin()) it = (qu[b]).begin(); it != (qu[b]).end();              it++)           sol[it->second] = dp[it->first];       } else {         for (typeof((qu[b]).begin()) it = (qu[b]).begin(); it != (qu[b]).end();              it++)           sol[it->second] = solve(it->first, b);       }     }     for (long long q = 1; q <= Q; q++) cout << sol[q] <<   n ;   }   