#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
int main() {
  istream &fin = cin;
  ostream &fout = cout;
  FILE *fpin = stdin;
  FILE *fpout = stdout;
  int n;
  fin >> n;
  int w[300010];
  for (int i = 0; i < n; i++) fin >> w[i];
  int p;
  fin >> p;
  vector<vector<long long> > ab(p);
  for (int i = 0; i < p; i++) {
    ab[i].resize(4);
    fin >> ab[i][1] >> ab[i][0];
    ab[i][1]--;
    ab[i][2] = i;
  }
  sort(ab.begin(), ab.end());
  long long dp[300010];
  int rtn = (int)sqrt((double)n);
  int pb = -1;
  for (int i = 0; i < p; i++) {
    int a = ab[i][1], b = ab[i][0];
    if (b != pb && b <= rtn) {
      for (int j = 0; j < n; j++) {
        if (j - b < 0)
          dp[j] = w[j];
        else
          dp[j] = dp[j - b] + w[j];
      }
    }
    pb = b;
    long long res = 0;
    if (b <= rtn) {
      int num = (n - (a - b + 1)) / b;
      int last = (a - b) + b * num;
      res = dp[last] - dp[a] + w[a];
    } else {
      for (int j = a; j < n; j += b) {
        res += w[j];
      }
    }
    ab[i][3] = res;
    swap(ab[i][0], ab[i][2]);
  }
  sort(ab.begin(), ab.end());
  for (int i = 0; i < p; i++) {
    fout << ab[i][3] << endl;
  }
}
