#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int mod = 1e9 + 7;
long long sum[N];
long long a[N];
vector<pair<int, int> > num[N];
long long ans[N];
int main() {
  int n;
  cin >> n;
  int block = sqrt(n);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  int m;
  cin >> m;
  for (i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (y > block) {
      for (int j = x; j <= n; j += y) {
        ans[i] += a[j];
      }
    } else {
      num[y].push_back({i, x});
    }
  }
  for (i = 1; i <= block; i++) {
    if (num[i].size()) {
      for (int j = n; j >= 1; j--) {
        sum[j] = (j + i > n ? 0 : sum[i + j]) + a[j];
      }
      for (auto x : num[i]) {
        ans[x.first] = sum[x.second];
      }
    }
  }
  for (i = 1; i <= m; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
