#include <bits/stdc++.h>
using namespace std;
int n, m, blo;
long long v[300005];
long long suf[300005];
struct node {
  int a, b, s;
  long long ans;
} d[300005];
bool cmp1(node x, node y) { return x.b < y.b; }
bool cmp2(node x, node y) { return x.s < y.s; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  blo = sqrt(n);
  for (int i = 1; i <= n; i++) cin >> v[i];
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> d[i].a >> d[i].b;
    d[i].s = i;
  }
  sort(d + 1, d + m + 1, cmp1);
  int cnt = -1;
  for (int i = 1; i <= m; i++) {
    if (d[i].b < blo) {
      if (cnt == d[i].b)
        d[i].ans = suf[d[i].a];
      else {
        cnt = d[i].b;
        for (int j = n; j >= 1; j--) {
          if (j + d[i].b > n)
            suf[j] = v[j];
          else
            suf[j] = suf[j + d[i].b] + v[j];
        }
        d[i].ans = suf[d[i].a];
      }
    } else {
      for (int j = d[i].a; j <= n; j += d[i].b) d[i].ans += v[j];
    }
  }
  sort(d + 1, d + m + 1, cmp2);
  for (int i = 1; i <= m; i++) {
    cout << d[i].ans << endl;
  }
  return 0;
}
