#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m;
long long dp[300005];
int a[300005];
long long ans[300005];
pair<pair<int, int>, int> q[300005];
bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second < b.first.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> q[i].first.first >> q[i].first.second;
    q[i].second = i;
  }
  sort(q, q + m, comp);
  int kek = (int)sqrt(n);
  int pr = -1;
  for (int i = 0; i < m; ++i) {
    if (q[i].first.second >= kek) {
      long long res = 0;
      for (int j = q[i].first.first; j <= n; j += q[i].first.second) {
        res += a[j];
      }
      ans[q[i].second] = res;
    } else {
      if (q[i].first.second != pr) {
        for (int j = n; j >= 1; --j) {
          if (j + q[i].first.second > n)
            dp[j] = a[j];
          else
            dp[j] = dp[j + q[i].first.second] + a[j];
        }
      }
      ans[q[i].second] = dp[q[i].first.first];
    }
    pr = q[i].first.second;
  }
  for (int i = 0; i < m; ++i) cout << ans[i] << '\n';
}
