#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 6;
const int sz = 500;
long long a[maxi], rez[maxi];
int x, y;
vector<long long> v[502];
pair<pair<int, int>, int> b[maxi];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  int q;
  cin >> q;
  int cnt = 0;
  for (int qq = 1; qq <= q; qq++) {
    scanf("%d%d", &x, &y);
    if (y >= sz) {
      long long ans = 0;
      for (int i = x; i <= n; i += y) ans += a[i];
      rez[qq] = ans;
    } else {
      cnt++;
      b[cnt] = {{y, x}, qq};
    }
  }
  sort(b + 1, b + cnt + 1);
  for (int i = 1; i <= cnt; i++)
    if (b[i].first.first == b[i - 1].first.first) {
      int y = b[i].first.first;
      int x = b[i].first.second;
      int query = b[i].second;
      long long prvi = v[x % y][x / y];
      long long zadnji = v[x % y][v[x % y].size() - 1];
      rez[query] = zadnji - prvi;
    } else {
      int y = b[i].first.first;
      int x = b[i].first.second;
      int query = b[i].second;
      for (int j = 0; j < y; j++) v[j].clear();
      for (int j = 0; j < y; j++) {
        v[j].push_back(0);
        long long tot = 0;
        for (int k = j; k <= n; k += y) {
          tot += a[k];
          v[j].push_back(tot);
        }
      }
      long long prvi = v[x % y][x / y];
      long long zadnji = v[x % y][v[x % y].size() - 1];
      rez[query] = zadnji - prvi;
    }
  for (int i = 1; i <= q; i++) printf("%lld\n", rez[i]);
  return 0;
}
