#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, size, p;
long long sol[N], dp[N], w[N];
struct query {
  int a, b, id;
  bool operator<(query a) const { return b < a.b; }
} q[N];
int main() {
  scanf("%d", &n);
  size = sqrt(n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &w[i]);
  scanf("%d", &p);
  for (int i = 0; i < p; i++) {
    scanf("%d %d", &q[i].a, &q[i].b);
    q[i].id = i;
  }
  sort(q, q + p);
  for (int i = 0; i < p; i++) {
    if (q[i].b > size) {
      sol[q[i].id] = 0;
      for (int j = q[i].a; j <= n; j += q[i].b) sol[q[i].id] += w[j];
    } else {
      if (i == 0 or q[i].b != q[i - 1].b) {
        for (int j = n; j >= 1; j--) {
          if (j + q[i].b > n)
            dp[j] = w[j];
          else
            dp[j] = w[j] + dp[j + q[i].b];
        }
      }
      sol[q[i].id] = dp[q[i].a];
    }
  }
  for (int i = 0; i < p; i++) printf("%I64d\n", sol[i]);
}
