#include <bits/stdc++.h>
using namespace std;
int n, q;
const int mxn = 300007;
int w[mxn];
struct query {
  int a, b, id;
  long long sub;
  bool operator<(const query& p) const {
    if (b == p.b) return a < p.a;
    return b < p.b;
  }
};
query p[mxn];
long long mod[mxn];
long long sol[mxn];
int main(int argc, char** argv) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    p[i].id = i;
    scanf("%d", &p[i].a);
    scanf("%d", &p[i].b);
  }
  sort(p, p + q);
  int SQRTN = (int)round(sqrt(n));
  for (int i = 0; i < q;) {
    int B = p[i].b;
    if (B <= SQRTN) {
      for (int m = 0; m < B; m++) mod[m] = 0;
      int j = i;
      while (j < q && p[j].b == p[i].b) {
        j++;
      }
      int ptr = j - 1;
      for (int pos = n, f = n % B; pos >= 0; pos--, f--) {
        if (f < 0) f = B - 1;
        mod[f] += w[pos];
        while (ptr >= i && p[ptr].a == pos) {
          p[ptr].sub = mod[f];
          ptr--;
        }
      }
      for (int pos = i; pos < j; pos++) {
        sol[p[pos].id] = p[pos].sub;
      }
      i = j;
    } else {
      long long& sum = sol[p[i].id];
      sum = 0;
      for (int pos = p[i].a; pos <= n; pos += p[i].b) {
        sum += w[pos];
      }
      i = i + 1;
    }
  }
  if (1)
    for (int i = 0; i < q; i++) printf("%I64d\n", sol[i]);
  return 0;
}
