#include <bits/stdc++.h>
using namespace std;
const int KEK = 512;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  vector<vector<pair<int, int>>> qs(KEK, vector<pair<int, int>>());
  vector<long long> ans(q);
  int k, b;
  for (int i = 0; i < q; ++i) {
    cin >> b >> k;
    --b;
    long long sum = 0;
    if (k >= KEK) {
      for (int j = b; j < n; j += k) {
        sum += a[j];
      }
    } else {
      qs[k].push_back({b, i});
    }
    ans[i] = sum;
  }
  vector<long long> sums(n);
  vector<vector<int>> nums(n);
  for (int len = 1; len < KEK; ++len) {
    sums.assign(n, 0);
    nums.assign(n, vector<int>());
    for (auto kek : qs[len]) {
      nums[kek.first].push_back(kek.second);
    }
    for (int i = n - 1; i >= 0; --i) {
      if (i + len < n) {
        sums[i] = a[i] + sums[i + len];
      } else {
        sums[i] = a[i];
      }
      for (int num : nums[i]) {
        ans[num] = sums[i];
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    cout << ans[i] << '\n';
  }
}
