#include <bits/stdc++.h>
typedef struct node {
  int a;
  int b;
  int index;
  long long int answer;
} node;
int mass[1000000];
long long int DP[1000000];
node parameters[1000000];
int compar(const void* a, const void* b) {
  return (*(node*)a).b - (*(node*)b).b;
}
int comp(const void* a, const void* b) {
  return (*(node*)a).index - (*(node*)b).index;
}
int main() {
  int n, i, p, a, b, k;
  long long int answer;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &mass[i]);
  scanf("%d", &p);
  for (i = 0; i < p; i++) {
    scanf("%d %d", &parameters[i].a, &parameters[i].b);
    parameters[i].index = i;
  }
  qsort(parameters, p, sizeof(node), compar);
  int j;
  for (i = 0; i < p; i++) {
    if (parameters[i].b < sqrt(n)) {
      if (parameters[i].b == parameters[i - 1].b && i > 0) {
        answer = DP[parameters[i].a];
      } else {
        for (j = n; j > 0; j--) {
          if (j + parameters[i].b > n)
            DP[j] = mass[j - 1];
          else
            DP[j] = DP[j + parameters[i].b] + mass[j - 1];
        }
        answer = DP[parameters[i].a];
      }
      parameters[i].answer = answer;
      continue;
    }
    answer = 0;
    k = 0;
    a = parameters[i].a;
    b = parameters[i].b;
    while ((a + b * k) <= n) {
      answer = answer + mass[a + b * k - 1];
      k++;
    }
    parameters[i].answer = answer;
  }
  qsort(parameters, p, sizeof(node), comp);
  for (i = 0; i < p; i++) {
    printf("%I64d\n", parameters[i].answer);
  }
  return 0;
}
