#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
ll get_seed(string s) {
  ll ans = 0;
  for (int i = 0; i < s.size(); ++i) ans += s[i];
  return ans;
}
int _sex = 600;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int q;
  cin >> q;
  vector<ll> ans(q);
  vector<vector<pair<int, int>>> ai(_sex);
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    if (b >= _sex) {
      for (int yi = a; yi < n; yi += b) {
        ans[i] += arr[yi];
      }
      continue;
    }
    ai[b].push_back({a, i});
  }
  vector<ll> sum(n);
  for (int j = _sex - 1; j > 0; --j) {
    if (ai[j].size() == 0) continue;
    sort((ai[j]).begin(), (ai[j]).end());
    for (int i = n - 1; i >= 0; --i) {
      sum[i] = (i + j < n ? sum[i + j] : 0) + arr[i];
      while (ai[j].back().first == i) {
        ans[ai[j].back().second] = sum[i];
        ai[j].pop_back();
        if (ai[j].size() == 0) break;
      }
    }
  }
  for (auto i : ans) cout << i << " ";
}
