#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1, M = 600;
int a[N];
long long b[M], ans[N];
vector<pair<int, int> > en[M], st[N];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    if (y >= M) {
      for (int j = x; j <= n; j += y) {
        ans[i] += a[j];
      }
    } else {
      st[y].push_back(make_pair(x, i));
      en[y].push_back(make_pair(x, i));
    }
  }
  for (int j = 1; j < M; j++) {
    sort(st[j].begin(), st[j].end());
    int ptr = 0;
    memset(b, 0, sizeof b);
    for (int i = 1; i <= n; i++) {
      while (ptr < st[j].size() && st[j][ptr].first < i) ++ptr;
      while (ptr < st[j].size() && st[j][ptr].first == i) {
        ans[st[j][ptr].second] -= b[st[j][ptr].first % j];
        ++ptr;
      }
      b[i % j] += a[i];
    }
    for (auto z : en[j]) {
      int idx, x;
      tie(x, idx) = z;
      ans[idx] += b[x % j];
    }
  }
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << endl;
  }
}
