#include <bits/stdc++.h>
using namespace std;
int N, A, B;
int V[300000];
long long ans[300000];
vector<pair<int, int> > lis[300];
long long dp[300000];
int Q;
int main() {
  scanf("%d", &N);
  for (int(i) = 0; (i) < (N); (i)++) scanf("%d", &V[i]);
  scanf("%d", &Q);
  for (int(ii) = 0; (ii) < (Q); (ii)++) {
    scanf("%d%d", &A, &B);
    A--;
    if (B >= 300) {
      long long res = 0;
      for (int i = A; i < N; i += B) res += V[i];
      ans[ii] = res;
    } else
      lis[B].push_back(make_pair(ii, A));
  }
  for (int(b) = (1); (b) < (300); (b)++) {
    for (int(i) = 0; (i) < (N); (i)++) dp[i] = V[i];
    for (int i = N - 1; i >= 0; i--)
      if (i + b < N) dp[i] += dp[i + b];
    for (int(i) = 0; (i) < (lis[b].size()); (i)++)
      ans[lis[b][i].first] = dp[lis[b][i].second];
  }
  for (int(i) = 0; (i) < (Q); (i)++) printf("%I64d\n", ans[i]);
}
