#include <bits/stdc++.h>
using namespace std;
int W[300010];
long long res[300010];
long long tab[300010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &W[i]);
  int p;
  scanf("%d", &p);
  vector<pair<pair<int, int>, int> > V(p);
  for (int i = 0; i < p; i++) {
    scanf("%d %d", &V[i].first.second, &V[i].first.first);
    V[i].second = i;
  }
  sort(V.begin(), V.end());
  int c = sqrt((double)n);
  int tmp = 0;
  for (int i = 0; i < V.size(); i++) {
    int a = V[i].first.second;
    int b = V[i].first.first;
    int k = V[i].second;
    res[k] = 0;
    if (b > c)
      for (int i = a; i <= n; i += b) res[k] += W[i];
    else {
      if (b != tmp) {
        for (int i = n; i > n - b; i--) tab[i] = W[i];
        for (int i = n - b; i >= 1; i--) tab[i] = tab[i + b] + W[i];
      }
      res[k] = tab[a];
    }
    tmp = b;
  }
  for (int i = 0; i < p; i++) printf("%I64d\n", res[i]);
exit:
  return (0);
}
