#include <bits/stdc++.h>
using namespace std;
long long int p2[312345], ans[312345];
int p[312345];
vector<pair<int, int> > vec[312345];
int main() {
  int n, i, q, a, b, k, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    if (b < 400) {
      vec[b].push_back(make_pair(a, i));
    } else {
      ans[i] = 0;
      while (a <= n) {
        ans[i] += p[a];
        a += b;
      }
    }
  }
  for (i = 1; i < 400; i++) {
    if (vec[i].size() == 0) {
      continue;
    }
    sort(vec[i].begin(), vec[i].end());
    k = vec[i].size() - 1;
    for (j = n; j >= 1; j--) {
      p2[j] = p[j];
      if (j + i <= n) {
        p2[j] += p2[i + j];
      }
      while (k >= 0) {
        if (vec[i][k].first < j) {
          break;
        }
        ans[vec[i][k].second] = p2[j];
        k--;
      }
    }
  }
  for (i = 0; i < q; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
