#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 100;
long long w[N], ans[N], sum[N];
int n, p, A, B, sq;
struct Query {
  int id, a, b;
  bool operator<(const Query &s) const { return b < s.b; }
} q[300010];
int main() {
  while (~scanf("%d", &n)) {
    sq = sqrt(n);
    for (int i = 1; i <= n; i++) {
      scanf("%I64d", &w[i]);
    }
    scanf("%d", &p);
    for (int i = 1; i <= p; i++) {
      q[i].id = i;
      scanf("%d%d", &q[i].a, &q[i].b);
    }
    q[0].b = 0;
    sort(q + 1, q + p + 1);
    for (int i = 1; i <= p; i++) {
      if (q[i].b < sq) {
        if (q[i].b != q[i - 1].b) {
          for (int j = n; j >= 1; j--) {
            if (j > n - q[i].b)
              sum[j] = w[j];
            else
              sum[j] = sum[j + q[i].b] + w[j];
          }
        }
        ans[q[i].id] = sum[q[i].a];
      } else {
        ans[q[i].id] = 0;
        for (int j = q[i].a; j <= n; j += q[i].b) ans[q[i].id] += w[j];
      }
    }
    for (int i = 1; i <= p; i++) {
      printf("%I64d\n", ans[i]);
    }
  }
  return 0;
}
