#include <bits/stdc++.h>
using namespace std;
struct req {
  int a, num;
};
int w[310000];
vector<req> z[610];
long long m[310000] = {}, res[310000] = {};
int main() {
  int n, p;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> w[i];
  cin >> p;
  for (int i = 0; i < p; i++) {
    int _a, _b;
    cin >> _a >> _b;
    _a--;
    if (_b < 600) {
      struct req l;
      l.num = i;
      l.a = _a;
      z[_b].push_back(l);
    } else
      while (_a < n) {
        res[i] += w[_a];
        _a += _b;
      }
  }
  for (int i = 1; i < 600; i++)
    if (z[i].size()) {
      for (int j = n - 1; j >= 0; j--) {
        long long s = 0;
        if (i + j < n) s = m[j + i];
        m[j] = s + w[j];
      }
      for (int j = 0; j < z[i].size(); j++) res[z[i][j].num] = m[z[i][j].a];
      memset(m, 0, n);
    }
  for (int i = 0; i < p; i++) cout << res[i] << endl;
}
