#include <bits/stdc++.h>
const int N = 3e5 + 5;
int read() {
  char c = getchar();
  int k = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) k = (k << 3) + (k << 1) + c - 48;
  return k;
}
int n, m, nn, i, a[N];
long long ans[N], f[N];
int he[N];
struct edge {
  int l, to;
} e[N];
int main() {
  for (n = read(), i = 1; i <= n; i++) a[i] = read();
  for (m = read(), nn = sqrt(n), i = 1; i <= m; i++) {
    int x = read(), y = read();
    if (y >= nn) {
      long long k = 0;
      for (; x <= n; x += y) k += a[x];
      ans[i] = k;
    } else
      e[i].l = he[y], he[y] = i, e[i].to = x;
  }
  for (int x = 1; x < nn; x++)
    if (he[x]) {
      for (i = n; i > n - x; i--) f[i] = a[i];
      for (; i; i--) f[i] = a[i] + f[i + x];
      for (i = he[x]; i; i = e[i].l) ans[i] = f[e[i].to];
    }
  for (i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
}
