#include <bits/stdc++.h>
using namespace std;
const int N = 400000;
long long n, a[N], s[N], ans[N], p;
vector<pair<long long, int> > b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> p;
  for (int i = 0; i < p; i++) {
    long long x;
    long long y;
    cin >> x >> y;
    if (y > 500)
      for (int j = x; j <= n; j += y) ans[i] += a[j];
    else
      b[y].push_back({x, i});
  }
  for (int i = 1; i <= 500; i++) {
    for (int j = 1; j <= n; j++)
      if (j - i <= 0)
        s[j] = a[j];
      else
        s[j] = s[j - i] + a[j];
    for (auto j : b[i]) {
      int x = n / i * i + j.first % i;
      if (x > n) x -= i;
      if (j.first <= i)
        ans[j.second] = s[x];
      else
        ans[j.second] = s[x] - s[j.first - i];
    }
    for (int i = 1; i <= n; i++) s[i] = 0;
  }
  for (int i = 0; i < p; i++) cout << ans[i] << endl;
}
