#include <bits/stdc++.h>
using namespace std;
void desperate_optimization(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int N = 3e5;
long long arr[N + 5];
long long pref[N + 5];
vector<pair<pair<int, int>, int> > lstq;
long long res[N + 5];
bool cmp(pair<pair<int, int>, int> &A, pair<pair<int, int>, int> &B) {
  if (A.first.second != B.first.second) return A.first.second < B.first.second;
  if (A.first.first % A.first.second != B.first.first % B.first.second)
    return A.first.first % A.first.second < B.first.first % B.first.second;
  return A.first.first < B.first.first;
}
void hora(int tc) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    pair<pair<int, int>, int> tmp;
    cin >> tmp.first.first >> tmp.first.second;
    tmp.second = i;
    lstq.push_back(tmp);
  }
  sort(lstq.begin(), lstq.end(), cmp);
  int end = 0;
  for (int i = 0; i < q; i++) {
    int a = lstq[i].first.first;
    int b = lstq[i].first.second;
    int idx = lstq[i].second;
    if (i == 0 || a % b != lstq[i - 1].first.first % lstq[i - 1].first.second ||
        b != lstq[i - 1].first.second) {
      int base = a % b;
      pref[base] = arr[base];
      end = base;
      for (int j = base + b; j <= n; j += b) {
        pref[j] = pref[j - b] + arr[j];
        end = j;
      }
    }
    res[idx] = pref[end];
    if (a % b != a) res[idx] -= pref[a - b];
  }
  for (int i = 1; i <= q; i++) cout << res[i] << '\n';
}
int main() {
  desperate_optimization(10);
  int ntc = 1;
  for (int tc = 1; tc <= ntc; tc++) hora(tc);
  return 0;
}
