#include <bits/stdc++.h>
using namespace std;
struct Question {
  int a, b, idx;
  Question() {}
  Question(int a, int b, int idx) : a(a), b(b), idx(idx) {}
  inline bool operator<(const Question& rhs) const {
    if (b != rhs.b) return b < rhs.b;
    return a < rhs.a;
  }
};
int n;
const int BOUND = 512;
long long a[300002], b[300002];
Question questions[300002];
long long answers[300002];
int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int qn;
  cin >> qn;
  for (int i = 0; i < qn; i++) {
    int x, y;
    cin >> x >> y;
    questions[i] = Question(x - 1, y, i);
  }
  sort(questions, questions + qn);
  int last = 0;
  for (int i = 0; i < qn; i++) {
    Question& q = questions[i];
    if (q.b < BOUND && last != q.b) {
      last = q.b;
      for (int j = n - 1; j >= 0; j--) {
        b[j] = a[j];
        if (j + q.b < n) b[j] += b[j + q.b];
      }
    }
    if (q.b < BOUND) {
      answers[q.idx] = b[q.a];
    } else {
      answers[q.idx] = 0;
      for (int j = q.a; j < n; j += q.b) {
        answers[q.idx] += a[j];
      }
    }
  }
  for (int i = 0; i < qn; i++) cout << answers[i] << endl;
  return 0;
}
