#include <bits/stdc++.h>
using namespace std;
int N;
int w[300000];
long long s[600][500];
struct Q {
  int a, b;
};
Q q[300000];
long long ans[300000];
int head[501];
int main(int argc, char* argv[]) {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < (N); ++i) {
    scanf("%d", &w[i]);
  }
  int P;
  scanf("%d", &P);
  vector<vector<int> > qa(500);
  for (int i = 0; i < P; i++) {
    scanf("%d %d", &q[i].a, &q[i].b);
    q[i].a--;
    if (q[i].b < 500) {
      qa[q[i].b].push_back(i);
    }
  }
  for (int b = 1; b < 500; b++) {
    if (qa[b].size() == 0) continue;
    vector<vector<pair<int, int> > > mod(b);
    {
      for (int j = 0; j < qa[b].size(); j++) {
        int ind = qa[b][j];
        mod[q[ind].a % b].push_back(make_pair(q[ind].a, ind));
      }
    }
    for (int i = 0; i < mod.size(); i++) {
      if (mod[i].size() == 0) continue;
      vector<pair<int, int> >& cmod = mod[i];
      sort(cmod.begin(), cmod.end());
      long long res = 0;
      int pos = cmod.size() - 1;
      int sa = (N / b) * b + i;
      while (sa > N) sa -= b;
      while (sa + b < N) sa += b;
      for (int a = sa; pos >= 0; a -= b) {
        res += w[a];
        while (pos >= 0 && cmod[pos].first == a) {
          ans[cmod[pos].second] = res;
          pos--;
        }
      }
    }
  }
  for (int i = 0; i < P; i++) {
    if (q[i].b < 500) {
      cout << ans[i] << endl;
    } else {
      int b = q[i].b;
      long long res = 0;
      for (int a = q[i].a; a < N; a += b) {
        res += w[a];
      }
      cout << res << endl;
    }
  }
  return 0;
}
