#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005, MAXP = 300005;
struct query {
  int a, b, original;
  inline bool operator<(const query &o) const { return b < o.b; }
};
int N, P, cow[MAXN];
long long bsum[MAXN], answer[MAXP];
query raid[MAXP];
int main() {
  int i, j;
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", cow + i);
  scanf("%d", &P);
  for (i = 0; i < P; i++) {
    scanf("%d %d", &raid[i].a, &raid[i].b);
    raid[i].a--;
    raid[i].original = i;
  }
  sort(raid, raid + P);
  for (i = 0, j = 0; i < P && raid[i].b < 500; i = j) {
    while (j < P && raid[i].b == raid[j].b) j++;
    for (int k = N - 1; k >= 0; k--)
      bsum[k] = cow[k] + (k + raid[i].b < N ? bsum[k + raid[i].b] : 0);
    for (int k = i; k < j; k++) answer[raid[k].original] = bsum[raid[k].a];
  }
  while (i < P) {
    long long sum = 0;
    for (int k = raid[i].a; k < N; k += raid[i].b) sum += cow[k];
    answer[raid[i].original] = sum;
    i++;
  }
  for (i = 0; i < P; i++) printf("%I64d\n", answer[i]);
  return 0;
}
