#include <bits/stdc++.h>
using namespace std;
const long long root = 5e2;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (auto &x : a) cin >> x;
  vector<vector<long long>> dp(root + 1);
  long long q;
  cin >> q;
  vector<vector<long long>> qs(q);
  vector<long long> ans(q), id(q);
  for (long long i = 0; i < q; ++i) {
    long long x, y;
    cin >> x >> y;
    qs[i] = {y, x, i};
  }
  sort(qs.begin(), qs.end());
  for (long long i = 0; i < q; ++i) {
    id[qs[i][2]] = i;
  }
  vector<long long> last(n);
  for (long long i = 0; i < q; ++i) {
    long long x = qs[i][1] - 1, y = qs[i][0];
    if (qs[i][0] > root) {
      for (long long j = x; j < n; j += y) {
        ans[i] += a[j];
      }
    } else {
      if (!i or (qs[i][0] != qs[i - 1][0])) {
        for (long long j = 0; j < n; ++j) {
          last[j] = a[j];
          if (j - y >= 0) last[j] += last[j - y];
        }
      }
      long long l = x + (n - x - 1) / y * y;
      ans[i] = last[l] - last[x] + a[x];
    }
  }
  for (long long i = 0; i < q; ++i) {
    cout << ans[id[i]] << '\n';
  }
  return 0;
}
