#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = 500;
int arr[N];
long long ans[N];
struct query {
  int a, b, id;
  bool operator<(const query &t) const { return b < t.b; }
};
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  int q;
  cin >> q;
  vector<query> queries(q);
  for (int i = 0; i < q; ++i) {
    scanf("%d %d", &queries[i].a, &queries[i].b);
    queries[i].id = i;
  }
  sort(queries.begin(), queries.end());
  while (!queries.empty() && queries.back().b > M) {
    long long cur = 0;
    for (int i = queries.back().a; i <= n; i += queries.back().b) cur += arr[i];
    ans[queries.back().id] = cur;
    queries.pop_back();
  }
  reverse(arr + 1, arr + n + 1);
  map<int, vector<int> > partition;
  for (int i = 0; i < queries.size(); ++i) partition[queries[i].b].push_back(i);
  for (auto cur : partition) {
    int s = cur.first;
    vector<long long> psum(N);
    for (int i = 1; i <= n; ++i) psum[i] = (i >= s ? psum[i - s] : 0) + arr[i];
    for (int i : cur.second) {
      queries[i].a = (n + 1 - queries[i].a);
      ans[queries[i].id] = psum[queries[i].a];
    }
  }
  for (int i = 0; i < q; ++i) printf("%lld\n", ans[i]);
}
