#include <bits/stdc++.h>
using namespace std;
long double PI = acosl(-1);
bool compare_int(int a, int b) { return (a > b); }
bool compare_string(string a, string b) { return a.size() < b.size(); }
bool compare_pair(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second)
    return a.first < b.first;
  else
    return (a.second > b.second);
}
bool cmp(pair<string, int> x, pair<string, int> y) {
  return (x.second < y.second);
}
void NA() {
  printf("NO\n");
  exit(0);
}
void YA() {
  printf("YES\n");
  exit(0);
}
const int N = 300005;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y, q;
  cin >> n;
  int sz = sqrt(n);
  long long int a[n + 1], tmp[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  vector<long long int> res(q);
  vector<pair<int, pair<int, int> > > v;
  for (int i = 0; i < q; i++) {
    cin >> x >> y;
    v.push_back({y, {x, i}});
  }
  sort(v.begin(), v.end());
  int pre = -1;
  for (int i = 0; i < q; i++) {
    x = v[i].second.first - 1;
    y = v[i].first;
    int id = v[i].second.second;
    if (y >= sz) {
      for (int i = x; i < n; i += y) res[id] += a[i];
    } else {
      if (pre != y) {
        memset(tmp, 0, sizeof tmp);
        for (int i = n - 1; i >= 0; i--) {
          tmp[i] += a[i];
          if (i + y < n) tmp[i] += tmp[i + y];
        }
        pre = y;
      }
      res[id] = tmp[x];
    }
  }
  for (int i = 0; i < q; i++) {
    cout << res[i] << endl;
  }
}
