#include <bits/stdc++.h>
using namespace std;
long long num[300005];
long long tmp[300005];
struct node {
  int id;
  int a, b;
  long long ans;
  node() { ans = 0; }
} p[300005];
vector<node> v[300005];
int main() {
  int n;
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  int m;
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    p[i].a = a;
    p[i].b = b;
    p[i].id = i;
    p[i].ans = 0;
    if (b > 600) {
      for (j = a; j <= n; j += b) {
        p[i].ans += num[j];
      }
    } else
      v[b].push_back(p[i]);
  }
  for (i = 1; i <= 600; i++) {
    if (v[i].size() > 0) {
      for (j = n; j >= 1; j--) {
        tmp[j] = num[j];
        if (i + j <= n) {
          tmp[j] += tmp[i + j];
        }
      }
      for (j = 0; j < v[i].size(); j++) {
        p[v[i][j].id].ans = tmp[v[i][j].a];
      }
    }
  }
  for (i = 1; i <= m; i++) {
    printf("%I64d\n", p[i].ans);
  }
  return 0;
}
