#include <bits/stdc++.h>
using namespace std;
const int TSIZE = 350;
const int maxn = 300000 + 10;
vector<pair<int, int> > qSmall[TSIZE];
long long ans[maxn];
vector<long long> qsum[TSIZE];
int a[maxn], N, Q;
inline long long calc(int st, int b) {
  long long ans = 0;
  for (int i = st; i <= N; i += b) {
    ans += a[i];
  }
  return ans;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  scanf("%d", &Q);
  for (int i = 0; i < Q; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b < TSIZE) {
      qSmall[b].push_back(make_pair(a, i));
    } else {
      ans[i] = calc(a, b);
    }
  }
  for (int size = 1; size < TSIZE; ++size) {
    if (qSmall[size].empty()) {
      continue;
    }
    for (int i = 0; i < size; ++i) {
      qsum[i].clear();
    }
    int pos = 1 % size;
    for (int i = 1; i <= N; ++i) {
      qsum[pos].push_back(a[i]);
      ++pos;
      if (pos >= size) pos = 0;
    }
    for (int i = 0; i < size; ++i) {
      for (int j = 1; j < ((int)(qsum[i].size())); ++j) {
        qsum[i][j] += qsum[i][j - 1];
      }
    }
    for (int k = 0; k < ((int)(qSmall[size].size())); ++k) {
      int aPos = qSmall[size][k].second;
      int x = qSmall[size][k].first % size;
      int y = (qSmall[size][k].first - 1) / size;
      long long ret = qsum[x].back();
      if (y > 0) ret -= qsum[x][y - 1];
      ans[aPos] = ret;
    }
  }
  ios::sync_with_stdio(false);
  for (int i = 0; i < Q; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
