#include <bits/stdc++.h>
const int MAXN = 3e5 + 5;
const int SQ = 600;
int n, p, m, w[MAXN];
long long sum[MAXN], ans[MAXN];
std::vector<int> vec[SQ];
struct Ques {
  int a, b;
} ques[MAXN];
void ss(int x) {
  int step = ques[x].b;
  if (step > m) {
    long long res = 0;
    for (int i = ques[x].a; i <= n; i += step) res += w[i];
    ans[x] = res;
  } else {
    vec[step].push_back(x);
  }
}
void solve() {
  scanf("%d", &n);
  m = sqrt(n);
  for (int i = 1; i <= n; i++) scanf("%d", w + i);
  scanf("%d", &p);
  for (int i = 1; i <= p; i++) scanf("%d%d", &ques[i].a, &ques[i].b);
  for (int i = 1; i <= p; i++) ss(i);
  for (int i = 1; i <= m; i++) {
    memset(sum, 0, sizeof(sum));
    for (int j = n; j >= n - i + 1; j--) sum[j] = w[j];
    for (int j = n - i; j >= 1; j--) sum[j] = w[j] + sum[j + i];
    for (int x : vec[i]) ans[x] = sum[ques[x].a];
  }
  for (int i = 1; i <= p; i++) printf("%I64d\n", ans[i]);
}
int main() {
  solve();
  return 0;
}
