#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, a[300000], q;
long long sum[300000], ans[300000];
void run() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  scanf("%d", &q);
  vector<pair<int, pair<int, int> > > query;
  for (int i = 0; i < q; i++) {
    int s, t;
    scanf("%d%d", &s, &t);
    query.push_back(make_pair(t, make_pair(s, i)));
  }
  sort((query).begin(), (query).end());
  for (int i = 0; i < q; i++) {
    int s = query[i].second.first, t = query[i].first,
        id = query[i].second.second;
    if (t < 550) {
      if (i == 0 || t != query[i - 1].first) {
        for (int j = 0; j < t; j++)
          for (int k = n - j - 1; k >= 0; k -= t)
            sum[k] = (k + t < n ? sum[k + t] : 0) + a[k];
      }
      ans[id] = sum[s - 1];
    } else {
      long long tmp = 0;
      for (int i = s - 1; i < n; i += t) tmp += a[i];
      ans[id] = tmp;
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
}
int main() { run(); }
