#include <bits/stdc++.h>
using namespace std;
const long long int maxn = (3e5) + 10, mod = 1e9 + 7, SQ = 550;
long long int n, q, a[maxn], dp[maxn], ans[maxn];
vector<pair<pair<long long int, long long int>, long long int> > Q;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  cin >> q;
  for (long long int i = 1; i <= q; i++) {
    long long int s, k;
    cin >> s >> k;
    Q.push_back(make_pair(make_pair(k, s), i));
  }
  sort(Q.begin(), Q.end());
  for (long long int i = 0; i < q; i++) {
    long long int s = Q[i].first.second, k = Q[i].first.first;
    if (k <= SQ) {
      for (long long int i = n; i >= 1; i--) {
        if (i + k > n)
          dp[i] = a[i];
        else
          dp[i] = dp[i + k] + a[i];
      }
      ans[Q[i].second] = dp[s];
      while (i < q - 1 && Q[i + 1].first.first == Q[i].first.first) {
        i++;
        s = Q[i].first.second;
        ans[Q[i].second] = dp[s];
      }
    } else {
      long long int res = 0;
      for (long long int i = s; i <= n; i += k) res += a[i];
      ans[Q[i].second] = res;
    }
  }
  for (long long int i = 1; i <= q; i++) cout << ans[i] << endl;
  return 0;
}
