#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
vector<pair<pair<int, int>, int> > vc;
int n, a[MAXN], qa, qb, p, la = -1, lb = -1;
long long ans[MAXN], S[MAXN], K;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first == b.first.first)
    return a.first.second % a.first.first < b.first.second % b.first.first;
  return a.first.first < b.first.first;
}
void calc(int md, int mx) {
  la = md, lb = mx;
  K = -1;
  for (int i = md; i <= n; i += mx, K++)
    if (K != -1)
      S[K + 1] = S[K] + a[i];
    else
      S[K + 1] = a[i];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> p;
  for (int i = 0; i < p; i++) {
    cin >> qa >> qb;
    vc.push_back({{qb, qa}, i});
  }
  sort(vc.begin(), vc.end(), cmp);
  for (int i = 0; i < vc.size(); i++) {
    qa = vc[i].first.second, qb = vc[i].first.first;
    if (qa % qb != la || qb != lb) calc(qa % qb, qb);
    if (qa - qb < 0)
      ans[vc[i].second] = S[K];
    else
      ans[vc[i].second] = S[K] - S[(qa - qb) / qb];
  }
  for (int i = 0; i < p; i++) cout << ans[i] << '\n';
}
