#include <bits/stdc++.h>
using namespace std;
struct Query {
  int num, a, b;
  Query(int num = 0, int a = 0, int b = 0) : num(num), a(a), b(b) {}
  bool operator<(const Query& q) const& { return b < q.b; }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const int k = 451;
  int q;
  cin >> q;
  vector<Query> query;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    query.emplace_back(i, a - 1, b);
  }
  int prev_b = -1;
  sort(query.begin(), query.end());
  vector<long long> sum(n);
  vector<long long> ans(q);
  for (int i = 0; i < q; i++) {
    if (query[i].b > k) {
      long long sum = 0;
      for (int j = query[i].a; j < n; j += query[i].b) {
        sum += a[j];
      }
      ans[query[i].num] = sum;
    } else {
      if (prev_b == query[i].b) {
        ans[query[i].num] = sum[query[i].a];
      } else {
        prev_b = query[i].b;
        for (int j = n - 1; j > -1; j--) {
          sum[j] = a[j] + (j + query[i].b < n ? sum[j + query[i].b] : 0);
        }
        ans[query[i].num] = sum[query[i].a];
      }
    }
  }
  for (auto u : ans) {
    cout << u << '\n';
  }
}
