#include <bits/stdc++.h>
using namespace std;
int n, x, y, q;
int a[300005];
long long ans[300005], res[500 + 5][500 + 5];
vector<pair<pair<int, int>, int> > query;
void print() {
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
}
void solve() {
  int last = n + 1;
  for (auto x : query) {
    int ind = x.first.first;
    int inc = x.first.second;
    int wh = x.second;
    while (last - 1 >= 1 && last - 1 >= ind) {
      last--;
      for (int i = 1; i <= 500; i++) {
        res[i][last % i] += a[last];
      }
    }
    ans[wh] = res[inc][ind % inc];
  }
}
long long solve_naive(int x, int y) {
  long long res = 0;
  for (int i = x; i <= n; i += y) res += a[i];
  return res;
}
void store() {
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &x, &y);
    if (y > 500) {
      ans[i] = solve_naive(x, y);
    } else {
      query.push_back({{x, y}, i});
    }
  }
  sort(query.begin(), query.end(), greater<pair<pair<int, int>, int> >());
}
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
}
int main() {
  read();
  store();
  solve();
  print();
}
