#include <bits/stdc++.h>
using namespace std;
const int MN = 300010;
const long long MOD = 4294967296;
int n;
int w[MN], p;
long long ans[MN], dp[MN + 550];
vector<pair<int, int> > q[533];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  scanf("%d", &p);
  for (int i = 0; i < p; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    if (b >= 500) {
      long long t = 0;
      for (int j = a; j < n; j += b) t += w[j];
      ans[i] = t;
    } else {
      q[b].push_back(make_pair(a, i));
    }
  }
  for (int i = 1; i < 500; i++) {
    if (!q[i].empty()) {
      for (int j = n - 1; j >= 0; j--) {
        dp[j] = w[j] + dp[j + i];
      }
      for (int j = 0; j < q[i].size(); j++)
        ans[q[i][j].second] = dp[q[i][j].first];
    }
  }
  for (int i = 0; i < p; i++) printf("%I64d\n", ans[i]);
  return 0;
}
