#include <bits/stdc++.h>
using namespace std;
int sq, n, m;
long long a[300000 + 500];
long long ans[300000 + 500], sum[300000 + 500];
struct Query {
  int id, a, b;
} q[300000 + 500];
bool cmp(const Query& a, const Query& b) { return a.b < b.b; }
int main() {
  scanf("%d", &n);
  sq = sqrt(n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    q[i].id = i;
    scanf("%d%d", &q[i].a, &q[i].b);
  }
  q[0].b = 0;
  sort(q + 1, q + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    if (q[i].b < sq) {
      if (q[i].b != q[i - 1].b) {
        for (int j = n; j >= 1; j--) {
          if (j > n - q[i].b)
            sum[j] = a[j];
          else
            sum[j] = sum[j + q[i].b] + a[j];
        }
      }
      ans[q[i].id] = sum[q[i].a];
    } else {
      ans[q[i].id] = 0;
      while (q[i].a <= n) {
        ans[q[i].id] += a[q[i].a];
        q[i].a += q[i].b;
      }
    }
  }
  for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
  return 0;
}
