#include <bits/stdc++.h>
using namespace std;
long long U[300001], qq[300001], uns;
int A[300001], a[300001], b[300001], w[300001], i, j, n, m;
void sort1(int l, int r) {
  int i, j, x;
  i = l;
  j = r;
  x = b[(i + j) / 2];
  while (i <= j) {
    while (b[i] < x) i++;
    while (x < b[j]) j--;
    if (i <= j) {
      swap(b[i], b[j]);
      swap(a[i], a[j]);
      swap(w[i], w[j]);
      i++;
      j--;
    }
  }
  if (i < r) sort1(i, r);
  if (l < j) sort1(l, j);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> A[i];
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    w[i] = i;
  }
  sort1(1, m);
  b[0] = -1;
  for (i = 1; i <= m; i++) {
    if (b[i] >= 550) {
      uns = 0;
      for (j = a[i]; j <= n; j += b[i]) uns += A[j];
      U[w[i]] = uns;
    } else {
      if (b[i] == b[i - 1])
        U[w[i]] = qq[a[i]];
      else {
        for (j = n; j >= 1; j--) {
          qq[j] = A[j];
          if (j + b[i] <= n) qq[j] += qq[j + b[i]];
        }
        U[w[i]] = qq[a[i]];
      }
    }
  }
  for (i = 1; i <= m; i++) cout << U[i] << endl;
}
