#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n, m, a[maxn];
long long sum[maxn], ans[maxn];
struct query {
  int id, t, k;
  bool operator<(const query& q1) const { return k < q1.k; }
} q[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &q[i].t, &q[i].k);
    q[i].id = i;
  }
  sort(q, q + m);
  int last = 0;
  for (int i = 0; i < m; ++i) {
    if ((long long)q[i].k * q[i].k >= n) {
      for (int j = q[i].t; j <= n; j += q[i].k) ans[q[i].id] += a[j];
      continue;
    }
    if (last != q[i].k) {
      last = q[i].k;
      memset(sum, 0, sizeof(sum));
      for (int i = 1; i <= n; ++i)
        sum[i] = i >= last ? a[i] + sum[i - last] : a[i];
    }
    int pos = q[i].t + (n - q[i].t) / q[i].k * q[i].k;
    if (q[i].t >= q[i].k)
      ans[q[i].id] = sum[pos] - sum[q[i].t - q[i].k];
    else
      ans[q[i].id] = sum[pos];
  }
  for (int i = 0; i < m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
