#include <bits/stdc++.h>
using namespace std;
int n, w[1 << 20];
int tests, a[1 << 20], b[1 << 20];
long long ans[1 << 20];
vector<int> queries[1 << 20];
long long dp[1 << 20];
long long naive(long long a, long long b) {
  long long res = 0;
  for (int i = a; i <= n; i += b) res += w[i];
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  cin >> tests;
  for (int iter = 1; iter <= tests; iter++) {
    cin >> a[iter] >> b[iter];
    if (b[iter] > 512) {
      ans[iter] = naive(a[iter], b[iter]);
    } else {
      queries[b[iter]].push_back(iter);
    }
  }
  for (int i = 1; i <= 512; i++) {
    for (int j = n; j; --j) dp[j] = 0;
    for (int j = n; j; --j) {
      dp[j] = dp[j + i] + w[j];
    }
    for (int j = 0; j < queries[i].size(); j++) {
      int id = queries[i][j];
      ans[id] = dp[a[id]];
    }
  }
  for (int i = 1; i <= tests; i++) {
    cout << ans[i] << endl;
  }
  cout << endl;
  return 0;
}
