#include <bits/stdc++.h>
using namespace std;
class york {
 public:
  void solve();
};
struct block {
  int start;
  vector<long long> v;
};
const int X = 300000;
const int SQ = 512;
int n;
int w[X + 7];
int steps[SQ];
vector<block> vb[SQ];
void build() {
  for (int l = 1; l < SQ; ++l) {
    vector<long long> v(l + 1);
    for (int i = 0; i < l; ++i) {
      v.push_back(0);
    }
    steps[l] = sqrt(X / l) * 1.28;
    int STEP = steps[l];
    for (int start = 0; start + l * STEP < X; start += l * STEP) {
      for (int head = start; head < start + l * STEP; head += l) {
        for (int i = 0; i < l; ++i) {
          v[i] += w[head + i];
        }
      }
      block b;
      b.start = start + l * (STEP - 1);
      b.v = vector<long long>(v);
      vb[l].push_back(b);
    }
  }
}
long long cal(int step, int start, int end) {
  if (start >= end) return 0;
  if (step >= SQ) {
    long long sum = 0;
    for (int pos = start; pos < end; pos += step) {
      sum += w[pos];
    }
    return sum;
  } else {
    vector<block>& v = vb[step];
    int pos = start;
    long long val = w[pos];
    int magic = max(0, (end / step) / steps[step] - 3);
    for (int i = magic; i < v.size(); ++i) {
      if (v[i].start + start < end) {
        pos = v[i].start + start;
        val = v[i].v[start];
      } else {
        break;
      }
    }
    pos += step;
    while (pos < end) {
      val += w[pos];
      pos += step;
    }
    return val;
  }
}
void york::solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  build();
  int q;
  cin >> q;
  for (int _q = 0; _q < q; ++_q) {
    int a, b;
    cin >> a >> b;
    a--;
    long long ans = cal(b, a % b, n) - cal(b, a % b, a);
    cout << ans << endl;
  }
}
int main() {
  (new york())->solve();
  return 0;
}
