#include <bits/stdc++.h>
using namespace std;
long long a[300010], us[300010];
vector<long long> pre[104];
pair<long long, pair<long long, long long> > b[300010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, i, j, g, ans = 0, q, l, r;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> q;
  for (i = 1; i <= q; i++)
    cin >> b[i].second.first >> b[i].first, b[i].second.second = i;
  sort(b + 1, b + 1 + q);
  for (i = 1; i <= q; i++) {
    l = b[i].second.first, r = b[i].first;
    int no = b[i].second.second;
    if (r <= 100 && b[i].first != b[i - 1].first) {
      for (j = 1; j <= r; j++) {
        pre[j].clear();
        int ko = 1;
        pre[j].push_back(0);
        for (g = j; g <= n; g += r) {
          pre[j].push_back(0);
          pre[j][ko] = pre[j][ko - 1] + a[g];
          ko++;
        }
      }
      int y = (l - 1) % r + 1;
      int x = (n - y) / r + 1;
      int po = (l - y) / r;
      us[no] = pre[y][x] - pre[y][po];
    } else if (r <= 100) {
      int y = (l - 1) % r + 1;
      int x = (n - y) / r + 1;
      int po = (l - y) / r;
      us[no] = pre[y][x] - pre[y][po];
    } else {
      ans = 0;
      for (j = l; j <= n; j += r) ans += a[j];
      us[no] = ans;
    }
  }
  for (i = 1; i <= q; i++) cout << us[i] << '\n';
}
