#include <bits/stdc++.h>
using namespace std;
struct data {
  int a, b, t;
} d[300010];
int qur, n, m, ed, a, b;
long long w[300010], sum, res[300010];
long long s[300010];
inline bool cmp(const data &x, const data &y) {
  if (x.b < y.b) return true;
  return false;
}
int main() {
  m = 0;
  ed = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    w[i] = (long long)tmp;
  }
  scanf("%d", &qur);
  for (int i = 1; i <= qur; ++i) {
    scanf("%d%d", &a, &b);
    if (b > 400) {
      sum = 0LL;
      for (int j = a; j <= n; j += b) sum += w[j];
      res[i] = sum;
    } else
      d[++m].a = a, d[m].b = b, d[m].t = i;
  }
  sort(d + 1, d + m + 1, cmp);
  for (int i = 1; i <= 400; ++i) {
    int END = max(n - i + 1, 1);
    for (int j = n; j >= END; --j) s[j] = w[j];
    for (int j = n - i; j >= 1; --j) s[j] = s[j + i] + w[j];
    for (; d[ed].b == i; ++ed) res[d[ed].t] = s[d[ed].a];
  }
  for (int i = 1; i <= qur; ++i) printf("%I64d\n", res[i]);
  return 0;
}
