#include <bits/stdc++.h>
using namespace std;
long long n, a, b, p, w[300005], dp[300005], ans[300005], prevv, m, anss;
pair<pair<long long, long long>, long long> q[300005];
int main() {
  scanf("%I64d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", &w[i]);
  scanf("%I64d", &p);
  for (int i = 0; i < p; i++) {
    scanf("%I64d %I64d", &a, &b);
    q[i] = make_pair(make_pair(b, a), i);
  }
  m = (int)sqrt(n);
  sort(q, q + p);
  prevv = 0;
  for (int i = 0; i < p; i++) {
    b = q[i].first.first;
    a = q[i].first.second;
    if (b <= m) {
      if (b != prevv) {
        for (int i = n - b; i < n; i++) dp[i] = w[i];
        for (int i = n - b - 1; i >= 0; i--) dp[i] = w[i] + dp[i + b];
        prevv = b;
      }
      ans[q[i].second] = dp[a - 1];
    } else {
      anss = 0;
      for (int i = a - 1; i < n; i += b) {
        anss += w[i];
      }
      ans[q[i].second] = anss;
    }
  }
  for (int i = 0; i < p; i++) printf("%I64d\n", ans[i]);
}
