#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
long long n, p, a[maxn], sum[maxn], ans[maxn];
struct Query {
  long long x, y, id;
} q[maxn];
bool cmp(Query a, Query b) {
  if (a.y == b.y) return a.id < b.id;
  return a.y < b.y;
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  scanf("%lld", &p);
  for (int i = 1; i <= p; i++) {
    scanf("%lld %lld", &q[i].x, &q[i].y);
    q[i].id = i;
  }
  sort(q + 1, q + p + 1, cmp);
  int l = 1, r = 1;
  while (1) {
    if (l > p) break;
    while (q[r + 1].y == q[l].y) r++;
    if (q[r].y > sqrt(n)) {
      for (int i = l; i <= r; i++) {
        long long tem = 0;
        for (int j = q[i].x; j <= n; j += q[i].y) {
          tem += a[j];
        }
        ans[q[i].id] = tem;
      }
      l = r + 1;
      continue;
    }
    memset(sum, 0, sizeof(sum));
    for (int i = n; i >= n - q[l].y + 1; i--) {
      sum[i] = a[i];
    }
    for (int i = n - q[l].y; i >= 1; i--) {
      sum[i] += sum[i + q[l].y] + a[i];
    }
    for (int i = l; i <= r; i++) {
      ans[q[i].id] = sum[q[i].x];
    }
    l = r + 1;
  }
  for (int i = 1; i <= p; i++) printf("%lld\n", ans[i]);
}
