#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, q, a, b;
int A[300010];
pair<int, int> B[300010];
vector<pair<int, int> > v[700][700];
long long int C[300010];
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> A[i];
  cin >> q;
  int k = sqrt(n);
  for (int i = 0; i < q; i++) {
    cin >> B[i].first >> B[i].second;
    if (B[i].second <= k) {
      v[B[i].second][B[i].first % B[i].second].push_back(
          pair<int, int>(B[i].first, i));
    }
  }
  for (int j = 1; j <= k; j++) {
    for (int i = 0; i < j; i++) {
      long long int val = 0;
      sort(v[j][i].begin(), v[j][i].end());
      int idx = n - (n % j) + i;
      if (idx > n) idx -= j;
      for (int a = v[j][i].size() - 1; a >= 0; a--) {
        int u = v[j][i][a].first;
        while (idx >= u) {
          val += (long long int)A[idx];
          idx -= j;
        }
        C[v[j][i][a].second] = val;
      }
    }
  }
  for (int i = 0; i < q; i++) {
    if (B[i].second <= k) {
      cout << C[i] << endl;
      continue;
    }
    long long int val = 0;
    for (int j = B[i].first; j <= n; j += B[i].second)
      val += (long long int)A[j];
    cout << val << endl;
  }
  return 0;
}
