#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m, a[N], block;
long long sum[N], ans[N];
struct node {
  int id, w;
};
vector<node> q[600];
int main() {
  cin >> n;
  block = sqrt(n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  cin >> m;
  for (int l, r, i = 1; i <= m; ++i) {
    scanf("%d%d", &l, &r);
    if (r > block)
      for (int j = l; j <= n; j += r) ans[i] += a[j];
    else
      q[r].push_back(node{i, l});
  }
  for (int j = 1; j <= block; ++j) {
    if (q[j].size()) {
      for (int i = n; i >= 1; --i) sum[i] = a[i] + (i + j > n ? 0 : sum[i + j]);
      for (int i = 0; i < q[j].size(); ++i) ans[q[j][i].id] = sum[q[j][i].w];
    }
  }
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
