#include <bits/stdc++.h>
using namespace std;
long long ANS[310005];
int n;
int p;
int w[310005];
int x, y;
vector<pair<int, int> > Q[1000];
bool b[1000];
long long sum[310005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  scanf("%d", &p);
  int t = (int)sqrt(n);
  for (int test = 0; test < p; test++) {
    long long ans = 0;
    scanf("%d%d", &x, &y);
    if (y > t) {
      for (int i = x; i <= n; i += y) ans += w[i];
      ANS[test] = ans;
    } else {
      Q[y].push_back(make_pair(x, test));
      b[y] = true;
    }
  }
  for (int i = 1; i <= t; i++)
    if (b[i]) {
      for (int j = n; j >= 1; j--) sum[j] = sum[j + i] + w[j];
      for (int j = Q[i].size() - 1; j >= 0; j--) {
        pair<int, int> tmp = Q[i][j];
        ANS[tmp.second] = sum[tmp.first];
      }
    }
  for (int test = 0; test < p; test++) printf("%I64d\n", ANS[test]);
  return 0;
}
