#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long int LINF = INF * (long long int)INF;
const int MAXN = (int)3e5 + 5;
int n, m;
long long int w[MAXN];
int x[MAXN], y[MAXN];
vector<pair<int, int> > queries[MAXN];
long long int dp[MAXN];
long long int answer[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int(i) = (0); (i) < (n); (i)++) cin >> w[i];
  cin >> m;
  for (int(i) = (0); (i) < (m); (i)++) {
    cin >> x[i] >> y[i];
    x[i]--;
    queries[y[i]].push_back(make_pair(y[i], i));
  }
  int magic = sqrt(n);
  for (int(i) = (0); (i) < (n + 1); (i)++) {
    sort(queries[i].begin(), queries[i].end());
  }
  for (int(yval) = (0); (yval) < (n + 1); (yval)++) {
    if (yval < magic) {
      memset(dp, 0, sizeof(dp));
      for (int i = n - 1; i >= 0; i--) {
        dp[i] = (i + yval < n ? dp[i + yval] : 0) + w[i];
      }
    }
    for (int(it) = (0); (it) < (queries[yval].size()); (it)++) {
      int id = queries[yval][it].second;
      int a = x[id], b = y[id];
      if (b >= magic) {
        long long int tot = 0;
        for (int i = a; i < n; i += b) {
          tot += w[i];
        }
        answer[id] = tot;
      } else {
        answer[id] = dp[a];
      }
    }
  }
  for (int(i) = (0); (i) < (m); (i)++) cout << answer[i] << endl;
  return 0;
}
