#include <bits/stdc++.h>
using namespace std;
const int maxN = 3 * 100000 + 2;
struct node {
  int s, t, idx;
  inline void in() { scanf("%d %d", &s, &t); }
  inline bool operator<(const node &tmp) const { return t < tmp.t; }
};
static int nQ;
static node Q[maxN];
static int nA;
static int A[maxN];
static long long ans[maxN];
static long long sum[maxN];
int main() {
  while (scanf("%d", &nA) == 1) {
    for (int i = 1; i <= nA; ++i) scanf("%d", A + i);
    scanf("%d", &nQ);
    for (int i = 0; i < nQ; ++i) Q[i].idx = i, Q[i].in();
    sort(Q, Q + nQ);
    static int nT, pre_t;
    nT = pre_t = 0;
    for (int i = 0, j; i < nQ; ++i) {
      if (Q[i].t != pre_t && nT <= 360) {
        ++nT, pre_t = Q[i].t;
        for (j = 1; j <= nA; ++j) {
          sum[j] = A[j];
          if (j > Q[i].t) sum[j] += sum[j - Q[i].t];
        }
      }
      if (Q[i].t == pre_t) {
        ans[Q[i].idx] = sum[Q[i].s + (nA - Q[i].s) / Q[i].t * Q[i].t];
        if (Q[i].s > Q[i].t) ans[Q[i].idx] -= sum[Q[i].s - Q[i].t];
      } else {
        ans[Q[i].idx] = 0LL;
        for (j = Q[i].s; j <= nA; j += Q[i].t) ans[Q[i].idx] += A[j];
      }
    }
    for (int i = 0; i < nQ; ++i) printf("%I64d\n", ans[i]);
  }
  return 0;
}
