#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int a, b, c, d, i, j, n, m, k;
int mas[300001];
pair<pair<int, int>, pair<int, int> > q[300001];
long long ans[300001];
int cur[300001];
long long cs[300002];
inline bool cmp(const pair<pair<int, int>, pair<int, int> > &a,
                const pair<pair<int, int>, pair<int, int> > &b) {
  if (a.first.second != b.first.second)
    return a.first.second < b.first.second;
  else if (a.second.first != b.second.first)
    return a.second.first < b.second.first;
  else
    return a.first.first < b.first.first;
}
inline void solvesmall(int l, int r) {
  k = 0;
  for (int _n(r), i(l); i <= _n; i++) {
    cur[k++] = q[i].first.first;
    cs[k - 1] = 0;
  }
  cs[k] = 0;
  int delta = q[l].first.second, a = 0;
  for (int i = q[l].second.first; i < n; i += delta) {
    while (a < k && cur[a] <= i) ++a;
    cs[0] += mas[i];
    cs[a] -= mas[i];
  }
  for (int _n((k)-1), i(0); i <= _n; i++) {
    if (i) cs[i] += cs[i - 1];
    ans[q[i + l].second.second] = cs[i];
  }
}
inline void solve(int l, int r) {
  for (int _n(r), i(l); i <= _n; i++) {
    if (i != l && q[i].second.first == q[i - 1].second.first) continue;
    int a = i;
    while (a <= r && q[i].second.first == q[a].second.first) ++a;
    solvesmall(i, a - 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int _n((n)-1), i(0); i <= _n; i++) scanf("%d", &mas[i]);
  scanf("%d", &m);
  for (int _n((m)-1), i(0); i <= _n; i++) {
    scanf("%d%d", &q[i].first.first, &q[i].first.second);
    --q[i].first.first;
    q[i].second.first = q[i].first.first % q[i].first.second;
    q[i].second.second = i;
  }
  sort(q, q + m, cmp);
  for (int _n((m)-1), i(0); i <= _n; i++) {
    if (i && q[i].first.second == q[i - 1].first.second) continue;
    a = i;
    while (a < m && q[i].first.second == q[a].first.second) ++a;
    solve(i, a - 1);
  }
  for (int _n((m)-1), i(0); i <= _n; i++) printf("%I64d\n", ans[i]);
}
