#include <bits/stdc++.h>
using namespace std;
int n;
int D = 500;
int w[300300];
long long ans[300300];
vector<pair<int, int> > g[300300];
int m;
long long dp[555][555];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", w + i);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    if (b >= D) {
      ans[i] = 0;
      for (int j = a; j < n; j += b) ans[i] += w[j];
    } else {
      g[a].push_back(make_pair(b, i));
    }
  }
  int cur = D - 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int b = 1; b < D; b++) {
      dp[cur][b] = 0;
    }
    for (int b = 1; b < D; b++) {
      dp[cur][b] = w[i];
      if (i + b < n) {
        dp[cur][b] += dp[(cur + b) % D][b];
      }
    }
    for (int j = 0; j < g[i].size(); j++) {
      int b = g[i][j].first;
      int ind = g[i][j].second;
      ans[ind] = dp[cur][b];
    }
    cur = (cur - 1 + D) % D;
  }
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
  return 0;
}
