#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long int> T(n);
  for (int i = (0); i <= ((int)(T).size() - 1); ++i) cin >> T[i];
  int p;
  cin >> p;
  vector<pair<pair<int, int>, int> > Q(p);
  for (int i = (0); i <= ((int)(Q).size() - 1); ++i) {
    Q[i].second = i;
    cin >> Q[i].first.second >> Q[i].first.first;
  }
  sort(Q.begin(), Q.end());
  int last_b = -1, sqrt = 1;
  vector<long long int> ans;
  while (sqrt * sqrt < n) sqrt++;
  vector<long long int> res(p);
  for (int i = (0); i <= ((int)(Q).size() - 1); ++i) {
    int b = Q[i].first.first, a = Q[i].first.second - 1, id = Q[i].second;
    if (b == last_b)
      res[id] = ans[a];
    else if (b <= sqrt) {
      ans = T;
      for (int j = (n - b - 1); j >= (0); --j) ans[j] += ans[j + b];
      last_b = b;
      res[id] = ans[a];
    } else {
      res[id] = 0;
      for (int j = a; j < n; j += b) res[id] += T[j];
    }
  }
  for (int i = (0); i <= ((int)(res).size() - 1); ++i) cout << res[i] << '\n';
  return 0;
}
