#include <bits/stdc++.h>
using namespace std;
long long n, a[300100], m, x, y, k = 0;
long long d[300100];
pair<pair<long long, long long>, long long> q[300100];
long long ans[300100];
int main() {
  cin >> n;
  for (int i = 0, _n = (int)(n); i < _n; i++) cin >> a[i];
  cin >> m;
  for (int u = 0, _n = (int)(m); u < _n; u++) {
    scanf("%I64d %I64d", &x, &y);
    if (y * y <= n)
      q[k++] = make_pair(make_pair(y, x), u);
    else {
      ans[u] = 0;
      for (int j = x - 1; j < n; j += y) ans[u] += a[j];
    }
  }
  sort(q, q + k);
  long long b = 0;
  for (int u = 0, _n = (int)(k); u < _n; u++) {
    x = q[u].first.second;
    y = q[u].first.first;
    long long t = q[u].second;
    if (b == y)
      ans[t] = d[x - 1];
    else {
      for (int i = n - 1; i >= 0; i--)
        if (i + y >= n)
          d[i] = a[i];
        else
          d[i] = d[i + y] + a[i];
      b = y;
      ans[t] = d[x - 1];
    }
  }
  for (int i = 0, _n = (int)(m); i < _n; i++) printf("%I64d\n", ans[i]);
  return 0;
}
