#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, q, a, b, blo, arr[N];
struct node {
  int a, b, id;
} qq[N];
long long ans[N], dp[N];
bool cmp(node a, node b) {
  if (a.b != b.b) return a.b > b.b;
  return a.a < b.a;
}
int main() {
  scanf("%d", &n);
  blo = sqrt(n);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &qq[i].a, &qq[i].b);
    qq[i].id = i;
  }
  sort(qq + 1, qq + q + 1, cmp);
  int n_b = -1;
  for (int i = 1; i <= q; i++) {
    node nn = qq[i];
    if (nn.b >= blo) {
      for (int i = nn.a; i <= n; i += nn.b) ans[nn.id] += arr[i];
    } else {
      if (nn.b != n_b || dp[nn.a] == 0) {
        for (int j = n; j >= 1; j--) {
          if (j + nn.b > n)
            dp[j] = arr[j];
          else
            dp[j] = dp[j + nn.b] + arr[j];
        }
        n_b = nn.b;
      }
      ans[nn.id] = dp[nn.a];
    }
  }
  for (int i = 1; i <= q; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
