#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int G = 200;
const int D = 100;
const int inf = int(1e9);
int n, i, j, k, l, p, q, cnt, x, y, t, C, ed, a[300010], d[G + 1];
long long ans, res;
vector<pair<int, long long> > V[G + 1][G + 1];
int main() {
  read(n);
  for (i = 1; i <= n; i++) read(a[i]);
  for (i = 1; i <= G; i++) {
    d[i] = n / i / D;
    if (d[i] == 0) break;
    C = i;
    for (j = 1; j <= i; j++) {
      for (p = j, res = 0, cnt = 0; p <= n; p += i) {
        res += a[p];
        if ((++cnt) % d[i] == 0) V[i][j].push_back(make_pair(p, res)), res = 0;
      }
      if (res > 0) V[i][j].push_back(make_pair(n, res));
      V[i][j].push_back(make_pair(inf, 0));
      for (p = V[i][j].size() - 2; p >= 0; p--)
        V[i][j][p].second += V[i][j][p + 1].second;
    }
  }
  for (read(q); q; q--) {
    read(x);
    read(y);
    if (y <= C) {
      t = (x - 1) % y + 1;
      p = lower_bound(V[y][t].begin(), V[y][t].end(), make_pair(x, 0LL)) -
          V[y][t].begin();
      ans = V[y][t][p + 1].second;
      ed = V[y][t][p].first;
      for (i = x; i <= ed; i += y) ans += a[i];
    } else {
      ans = 0;
      for (i = x; i <= n; i += y) ans += a[i];
    }
    if (ans == 12392143763LL) printf("%d , %d %d:\n", x, y, C);
    printf("%I64d\n", ans);
  }
  scanf("\n");
  return 0;
}
