#include <bits/stdc++.h>
using namespace std;
const int Nmax = 300000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, weight[Nmax];
  long long ans[Nmax], result[Nmax];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> weight[i];
  int p, a, b;
  long long res;
  cin >> p;
  vector<pair<pair<int, int>, int>> q;
  for (int i = 0; i < p; ++i) {
    cin >> a >> b;
    q.push_back({{b, a}, i});
  }
  sort(q.begin(), q.end());
  int prev = 0;
  for (auto w : q) {
    if (w.first.first == prev) {
      result[w.second] = ans[w.first.second - 1];
      continue;
    }
    if (w.first.first < 300) {
      for (int i = n - 1; i >= 0; --i)
        if (i + w.first.first < n)
          ans[i] = weight[i] + ans[i + w.first.first];
        else
          ans[i] = weight[i];
      prev = w.first.first;
      result[w.second] = ans[w.first.second - 1];
      prev = w.first.first;
    } else {
      res = 0;
      for (int i = w.first.second - 1; i < n; i += w.first.first)
        res += weight[i];
      result[w.second] = res;
    }
  }
  for (int i = 0; i < p; ++i) {
    cout << result[i] << '\n';
  }
  return 0;
}
