#include <bits/stdc++.h>
using namespace std;
int ar[300005];
long long ans[300005];
char ch[300005];
int n, m, ii, k;
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
  scanf("%d", &m);
  vector<pair<int, pair<int, int>>> q;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (y > 555) {
      long long re = ar[x];
      while (x + y <= n) {
        x += y;
        re += ar[x];
      }
      ans[i] = re;
    } else
      q.push_back({y, {x, i}});
  }
  sort(q.begin(), q.end());
  k = q.size();
  for (int i = 0; i < k; i++) {
    int st = i;
    int en = i;
    while (en + 1 < k && q[i].first == q[en + 1].first) en++;
    vector<long long> dp(n + 5);
    int y = q[i].first;
    for (int j = n; j >= 1; j--) {
      dp[j] = ar[j];
      if (j + y <= n) dp[j] += dp[y + j];
    }
    for (int j = st; j <= en; j++) {
      ans[q[j].second.second] = dp[q[j].second.first];
    }
    i = en;
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
