#include <bits/stdc++.h>
using namespace std;
int ara[300005], n;
long long answer[300005];
vector<pair<int, int> > query[600];
long long dp[300005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &ara[i]);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int st, p;
    scanf("%d", &st);
    scanf("%d", &p);
    st--;
    if (p >= 550) {
      for (int j = st; j < n; j += p) answer[i] += ara[j];
      continue;
    }
    query[p].push_back(make_pair(st, i));
  }
  for (int i = 1; i < 550; i++) {
    for (int j = n - 1; j >= 0; j--) {
      dp[j] = ara[j];
      if (j + i < n) dp[j] += dp[j + i];
    }
    for (int j = 0; j < query[i].size(); j++)
      answer[query[i][j].second] = dp[query[i][j].first];
  }
  for (int i = 0; i < q; i++) printf("%I64d\n", answer[i]);
  return 0;
}
