#include <bits/stdc++.h>
using namespace std;
int gint() {
  char c;
  int f = 1;
  while (c = getchar(), c < 48 || c > 57)
    if (c == '-') f = -1;
  int x = 0;
  for (; c > 47 && c < 58; c = getchar()) {
    x = x * 10 + c - 48;
  }
  return x * f;
}
int n, m, B, a[300005];
long long b[550][550], ans[300005];
struct QY {
  int a, b, id;
  QY() {}
} Q[300005];
bool cmp(const QY& x, const QY& y) { return x.b < y.b; }
int main() {
  n = gint(), B = sqrt(n);
  for (int i = 1; i <= n; ++i) a[i] = gint();
  m = gint();
  for (int i = 1; i <= m; ++i) {
    Q[i].a = gint(), Q[i].b = gint();
    Q[i].id = i;
  }
  sort(Q + 1, Q + 1 + m, cmp);
  for (int i = 1; i <= m; ++i) {
    if (Q[i].b > B) {
      for (int j = Q[i].a; j <= n; j += Q[i].b) {
        ans[Q[i].id] += a[j];
      }
    } else {
      if (Q[i].b != Q[i - 1].b) {
        for (int j = 1; j <= (n - 1) / B + 1; ++j)
          for (int k = 0; k < Q[i].b; ++k) {
            b[j][k] = 0;
          }
        for (int j = 1; j <= n; ++j) {
          b[(j - 1) / B + 1][j % Q[i].b] += a[j];
        }
      }
      int k = (Q[i].a - 1) / B + 1;
      for (int j = Q[i].a; j <= k * B && j <= n; j += Q[i].b) {
        ans[Q[i].id] += a[j];
      }
      for (int j = k + 1; j <= (n - 1) / B + 1; ++j) {
        ans[Q[i].id] += b[j][Q[i].a % Q[i].b];
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
