#include <bits/stdc++.h>
using namespace std;
int data[300000 + 7], dpB;
long long ans[300000 + 7], dp[300000 + 7];
struct QR {
  int id, a, b;
  long long res;
};
int main() {
  vector<QR> queries;
  int n, p, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", data + i);
  scanf("%d", &p);
  for (int i = 0; i < p; i++) {
    scanf("%d %d", &a, &b);
    queries.push_back({i, a - 1, b});
  }
  sort(queries.begin(), queries.end(),
       [](const QR& a, const QR& b) { return a.b < b.b; });
  for (QR& x : queries) {
    if (x.b > 550) {
      for (long long i = x.a; i < n; i += x.b) x.res += data[i];
    } else {
      if (dpB != x.b) {
        for (long long i = n - 1; i >= 0; i--)
          if (i + x.b < n)
            dp[i] = data[i] + dp[i + x.b];
          else
            dp[i] = data[i];
      }
      dpB = x.b;
      x.res = dp[x.a];
    }
  }
  sort(queries.begin(), queries.end(),
       [](const QR& a, const QR& b) { return a.id < b.id; });
  for (QR x : queries) cout << x.res << endl;
}
