#include <bits/stdc++.h>
using namespace std;
long long a[300005];
struct qu {
  int id;
  int a, b;
  long long ans;
} p[300005];
vector<qu> q[505];
long long tmp[300005];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; i++) scanf("%I64d", a + i);
    int qq;
    scanf("%d", &qq);
    for (int i = 0; i < qq; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      p[i].a = x;
      p[i].b = y;
      p[i].ans = 0;
      p[i].id = i;
      if (y > 500) {
        for (int j = x; j <= n; j += y) p[i].ans += a[j];
      } else
        q[y].push_back(p[i]);
    }
    for (int i = 1; i <= 500; i++) {
      for (int j = n; j > 0; j--) {
        tmp[j] = a[j];
        if (j + i <= n) tmp[j] += tmp[j + i];
      }
      int sz = q[i].size();
      for (int j = 0; j < sz; j++) {
        long long t = tmp[q[i][j].a];
        p[q[i][j].id].ans = t;
      }
    }
    for (int i = 0; i < qq; i++) printf("%I64d\n", p[i].ans);
  }
  return 0;
}
