#include <bits/stdc++.h>
using namespace std;
long long n, m, a[310006], b[310006], c[310006], f[310006], ans[310006];
inline long long read() {
  long long x = 0, c = getchar();
  while (c < 48) c = getchar();
  while (c > 47) x = (x << 1) + (x << 3) + c - 48, c = getchar();
  return x;
}
void print(long long x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + 48);
}
int main() {
  n = read();
  for (long long i = 1; i <= n; i++) c[i] = read();
  m = read();
  for (long long i = 1; i <= m; i++) {
    a[i] = read();
    b[i] = read();
    if (b[i] * b[i] > n)
      for (long long j = a[i]; j <= n; j += b[i]) ans[i] += 1LL * c[j];
  }
  for (long long i = 1; i * i <= n; i++) {
    for (long long j = n; j >= 1; j--) f[j] = f[j + i] + 1LL * c[j];
    for (long long j = 1; j <= m; j++) ans[j] = b[j] == i ? f[a[j]] : ans[j];
  }
  for (long long i = 1; i <= m; i++) print(ans[i]), puts("");
}
