#include <bits/stdc++.h>
using namespace std;
const int N = 300 * 1000 + 20, SQ = 550;
int n, q, a[N], x[N], y[N];
long long dp[N], ans[N];
vector<pair<int, int> > todo[SQ];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> x[i] >> y[i];
    if (y[i] < SQ) todo[y[i]].push_back({--x[i], i});
  }
  for (int j = 1; j < SQ; j++) {
    for (int i = n - 1; ~i; i--) dp[i] = a[i] + (i + j < n ? dp[i + j] : 0);
    for (auto i : todo[j]) ans[i.second] = dp[i.first];
  }
  for (int i = 0; i < q; i++) {
    if (y[i] >= SQ) {
      for (int j = --x[i]; j < n; j += y[i]) ans[i] += a[j];
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << "\n";
  return 0;
}
