#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 20, inf = 1e17, SQ = 550;
long long n, A[maxn], p, tmp1, tmp2, ans[maxn], lb, ps[maxn];
vector<pair<pair<long long, long long>, long long> > V;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> p;
  for (long long i = 0; i < p; i++) {
    cin >> tmp1 >> tmp2;
    V.push_back({{tmp2, tmp1}, i});
  }
  sort(V.begin(), V.end());
  for (long long i = 0; i < p; i++) {
    long long b = V[i].first.first;
    if (b != lb) {
      if (b < SQ) {
        lb = b;
        for (long long j = n - 1; j >= 0; j--) {
          if (b + j >= n) {
            ps[j] = A[j];
          } else {
            ps[j] = ps[j + b] + A[j];
          }
        }
        ans[V[i].second] = ps[V[i].first.second - 1];
      } else {
        for (long long j = V[i].first.second - 1; j < n; j += b) {
          ans[V[i].second] += A[j];
        }
      }
    } else {
      ans[V[i].second] = ps[V[i].first.second - 1];
    }
  }
  for (long long i = 0; i < p; i++) {
    cout << ans[i] << endl;
  }
}
