#include <bits/stdc++.h>
using namespace std;
long long w[300100], n, p, ans[300100], d[300100];
pair<pair<long long, long long>, long long> q[300100];
void dir(long long b) {
  for (long long i = n - 1; i >= 0; --i)
    if (i + b < n)
      d[i] = d[i + b] + w[i];
    else
      d[i] = w[i];
}
long long sim(long long a, long long b) {
  long long an = 0;
  for (long long i = a; i < n; i += b) an += w[i];
  return an;
}
int main() {
  long long r, a, b;
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> w[i];
  cin >> p;
  for (long long i = 0; i < p; ++i) {
    cin >> a >> b;
    q[i] = make_pair(make_pair(b, a - 1), i);
  }
  sort(q, q + p);
  r = 1000;
  for (long long i = 0; i < p; ++i)
    if (q[i].first.first <= r) {
      if (i == 0 || q[i].first.first != q[i - 1].first.first)
        dir(q[i].first.first);
      ans[q[i].second] = d[q[i].first.second];
    } else
      ans[q[i].second] = sim(q[i].first.second, q[i].first.first);
  for (long long i = 0; i < p; ++i) cout << ans[i] << endl;
  return 0;
}
