#include <bits/stdc++.h>
using namespace std;
long long t, n, u, v, m, q, r, ql, qr, k, l, s, x, y, w, h, c, a, b;
const int N = 3e5 + 1;
const int SN = 1000;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57LL;
const bool JUDGE = false;
long long sum[N];
long long Ans[N];
vector<pair<int, int> > f[SN][SN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (JUDGE) {
    freopen("cricket.in", "r", stdin);
    freopen("cricket.out", "w", stdout);
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> sum[i];
  }
  cin >> q;
  for (int j = 0; j < q; ++j) {
    cin >> x >> y;
    x--;
    if (y >= SN) {
      for (int i = x; i < n; i += y) {
        Ans[j] += sum[i];
      }
    } else {
      f[y][x % y].push_back(make_pair(x, j));
    }
  }
  for (int i = 0; i < SN; ++i)
    for (int j = 0; j < SN; ++j) sort(f[i][j].begin(), f[i][j].end());
  for (int i = 0; i < SN; ++i) {
    for (int j = 0; j < SN; ++j) {
      if (f[i][j].size() == 0) continue;
      long long x = f[i][j].back().first;
      long long sol = 0;
      for (int k = x; k < n; k += i) sol += sum[k];
      int h = f[i][j].size() - 1;
      x = f[i][j].back().first;
      while (h >= 0) {
        while (x > f[i][j][h].first) {
          x -= i;
          sol += sum[x];
        }
        Ans[f[i][j][h].second] = sol;
        h--;
      }
    }
  }
  for (int i = 0; i < q; ++i) cout << Ans[i] << '\n';
  return 0;
}
