#include <bits/stdc++.h>
using namespace std;
struct Query {
  int p, s, id;
  bool operator<(const Query &b) const { return (s < b.s); }
};
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int m;
  scanf("%d", &m);
  vector<Query> q(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &q[i].p, &q[i].s);
    --q[i].p;
    q[i].id = i;
  }
  sort(q.begin(), q.end());
  vector<long long> ans(m, 0);
  int lim = sqrt(n);
  for (int i = 0; i < q.size(); ++i) {
    if (q[i].s > lim) {
      for (int j = q[i].p; j < n; j += q[i].s) ans[q[i].id] += a[j];
    } else {
      int cs = q[i].s;
      vector<long long> sums(n, 0);
      for (int j = n - 1; j >= 0; --j)
        sums[j] = a[j] + ((j + cs < n) ? sums[j + cs] : 0);
      int j;
      for (j = i; j < q.size() && q[j].s == cs; ++j)
        ans[q[j].id] = sums[q[j].p];
      i = j - 1;
    }
  }
  for (int i = 0; i < ans.size(); ++i) printf("%I64d\n", ans[i]);
  return 0;
}
