#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  long long p;
  cin >> p;
  long long q = sqrt(n);
  vector<pair<int, int>> big_b, less_b;
  map<pair<int, int>, vector<int>> mp;
  for (long long i = 0; i < p; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    mp[{a, b}].push_back(i);
    if (b >= q)
      big_b.push_back({a, b});
    else
      less_b.push_back({a, b});
  }
  vector<long long> ans(p, 0);
  for (auto now : big_b) {
    long long sum = 0;
    for (long long i = now.first; i < n; i += now.second) {
      sum += v[i];
    }
    ans[mp[now].back()] = sum;
    mp[now].pop_back();
  }
  for (long long i = 1; i < q; i++) {
    vector<long long> dp(n);
    for (long long j = n - 1; j >= 0; j--) {
      dp[j] = v[j];
      if (j + i < n) {
        dp[j] += dp[j + i];
      }
    }
    for (auto now : less_b) {
      if (now.second == i) {
        ans[mp[now].back()] = dp[now.first];
        mp[now].pop_back();
      }
    }
  }
  for (long long i = 0; i < p; i++) cout << ans[i] << '\n';
  return 0;
}
