#include <bits/stdc++.h>
using namespace std;
long long a[310000], s[310000], ans[310000];
int n;
struct node {
  int x, y, id;
} b[310000];
bool cmp(node a, node b) { return a.y < b.y; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &b[i].x, &b[i].y);
    b[i].id = i;
  }
  sort(b + 1, b + q + 1, cmp);
  for (int i = 1; i <= q; i++)
    if (b[i].y <= (int)sqrt(n)) {
      if (i > 1 && b[i].y == b[i - 1].y)
        ans[b[i].id] = s[b[i].x];
      else {
        for (int j = 1; j <= n; j++) s[j] = 0;
        for (int j = n; j >= 1; j--) {
          s[j] = a[j];
          if (j + b[i].y <= n) s[j] += s[j + b[i].y];
        }
        ans[b[i].id] = s[b[i].x];
      }
    } else {
      long long t = 0;
      int j = b[i].x;
      while (j <= n) {
        t += a[j];
        j += b[i].y;
      }
      ans[b[i].id] = t;
    }
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
