#include <bits/stdc++.h>
using namespace std;
long long int N = 1e9 + 7;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> w(n + 1);
  for (long long int i = 0; i < n; i++) {
    cin >> w[i];
  }
  vector<pair<pair<long long int, long long int>, long long int> > q;
  long long int p;
  cin >> p;
  vector<long long int> res(p);
  long long int a, b;
  for (long long int i = 0; i < p; i++) {
    cin >> a >> b;
    q.push_back({{b, a}, i});
  }
  sort(q.begin(), q.end());
  long long int b_prev = -1;
  long long int dp[n];
  memset(dp, 0, sizeof(dp));
  for (long long int i = 0; i < p; i++) {
    a = q[i].first.second;
    b = q[i].first.first;
    long long int idx = q[i].second;
    if (b > sqrt(n)) {
      for (long long int j = a; j <= n; j += b) {
        res[idx] += w[j - 1];
      }
    } else {
      if (b_prev == b) {
        res[idx] = dp[a - 1];
      } else {
        memset(dp, 0, sizeof(dp));
        b_prev = b;
        dp[n - 1] = w[n - 1];
        for (long long int i = n - 2; i >= 0; i--) {
          if (i + b <= n - 1) {
            dp[i] = dp[i + b] + w[i];
          } else {
            dp[i] = w[i];
          }
        }
        res[idx] = dp[a - 1];
      }
    }
  }
  for (auto v : res) {
    cout << v << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
