#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m, p, a[N];
pair<int, int> q[N];
long long res[N], F[N];
void Input() {
  cin >> n;
  p = sqrt(n);
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> q[i].first >> q[i].second;
    if (q[i].second >= p) {
      for (int j = q[i].first; j <= n; j += q[i].second) res[i] += a[j];
    }
  }
}
void Solve() {
  for (int i = 1; i < p; i++) {
    memset(F, 0, sizeof(F));
    for (int j = n; j >= 1; j--) F[j] = F[j + i] + a[j];
    for (int t = 1; t <= m; t++) {
      if (i == q[t].second) res[t] = F[q[t].first];
    }
  }
  for (int i = 1; i <= m; i++) cout << res[i] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  Input();
  Solve();
  return 0;
}
