#include <bits/stdc++.h>
using namespace std;
const long long maxn = 300005;
const long long sq = 550;
long long w[sq][sq];
long long arr[maxn];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  vector<pair<long long, long long>> queries[n + 1];
  long long q;
  cin >> q;
  long long res[q];
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    queries[a].push_back({b, i});
    res[i] = 0;
  }
  for (long long i = n; i >= 1; i--) {
    for (long long j = 1; j < sq; j++) w[j][i % j] += arr[i];
    for (pair<long long, long long> p : queries[i]) {
      long long b = p.first;
      long long id = p.second;
      if (b < sq) {
        res[id] = w[b][i % b];
      } else {
        for (long long j = i; j <= n; j += b) res[id] += arr[j];
      }
    }
  }
  for (long long i = 0; i < q; i++) cout << res[i] << '\n';
}
