#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[600005];
long long ans[600005], f[600005];
struct fuck {
  int x, y, pos;
} e[600005];
int read() {
  int x = 0, f = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
bool comp(fuck a, fuck b) { return a.y < b.y; }
int main() {
  n = read();
  k = sqrt(n);
  for (int i = 1; i <= n; i++) a[i] = read();
  m = read();
  for (int i = 1; i <= m; i++) e[i].x = read(), e[i].y = read(), e[i].pos = i;
  sort(e + 1, e + m + 1, comp);
  for (int i = 1; i <= m; i++) {
    if (e[i].y > k) {
      for (int j = e[i].x; j <= n; j += e[i].y) ans[e[i].pos] += a[j];
    } else {
      if (e[i].y != e[i - 1].y) {
        for (int j = n; j; j--) f[j] = a[j] + f[j + e[i].y];
      }
      ans[e[i].pos] = f[e[i].x];
    }
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
