#include <bits/stdc++.h>
using namespace std;
struct ww {
  int a, b, id;
} a[300010];
int i, j, k, n, m, p;
int b[300010];
long long f[300010], an[300010];
inline bool cc1(const ww &a, const ww &b) { return a.b < b.b; }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  scanf("%d", &m);
  for (i = 1; i <= m; i++) scanf("%d%d", &a[i].a, &a[i].b), a[i].id = i;
  sort(a + 1, a + m + 1, cc1);
  j = 1;
  for (i = 1; i <= 500; i++) {
    if (j <= m && a[j].b != i) continue;
    for (k = n; k; k--) {
      if (k + i <= n)
        f[k] = f[k + i];
      else
        f[k] = 0;
      f[k] += b[k];
    }
    for (; j <= m && a[j].b == i; j++) an[a[j].id] = f[a[j].a];
  }
  for (; j <= m; j++) {
    for (k = a[j].a; k <= n; k += a[j].b) an[a[j].id] += b[k];
  }
  for (i = 1; i <= m; i++) printf("%I64d\n", an[i]);
  return 0;
}
