#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = (int)1e9 + 7;
const int N = 3e5 + 100;
int n, m, k, p;
int w[N];
long long tot[N];
long long ans[N];
struct Node {
  int a, b, id;
} q[N];
bool cmp(Node x1, Node x2) { return x1.b < x2.b; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  scanf("%d", &p);
  k = sqrt(n);
  int t = 0, a, b;
  long long tmp;
  for (int i = 1; i <= p; i++) {
    scanf("%d%d", &a, &b);
    if (b >= k) {
      tmp = 0;
      for (int i = a; i <= n; i += b) tmp += w[i];
      ans[i] = tmp;
    } else {
      q[t].a = a;
      q[t].b = b;
      q[t].id = i;
      t++;
    }
  }
  sort(q, q + t, cmp);
  for (int i = 0; i < t; i++) {
    if (i == 0 || q[i].b != q[i - 1].b) {
      b = q[i].b;
      for (int i = n; i >= 1; i--) {
        if (i + b > n)
          tot[i] = w[i];
        else
          tot[i] = tot[i + b] + w[i];
      }
    }
    ans[q[i].id] = tot[q[i].a];
  }
  for (int i = 1; i <= p; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
