#include <bits/stdc++.h>
struct pair {
  int a, b, i;
  pair(int g = 0, int gg = 0, int ggg = 0) : a(g), b(gg), i(ggg) {}
  bool operator<(const pair &o) const { return b < o.b; }
};
int n;
int w[300001];
long long int ans[300001];
long long int dp[300001];
std::vector<pair> V;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  int t;
  scanf("%d", &t);
  for (int a, b, i = 0; i < t; ++i) {
    scanf("%d%d", &a, &b);
    V.push_back(pair(a, b, i));
  }
  std::sort(V.begin(), V.end());
  for (int i = 0; i < t; ++i) {
    if (V[i].b >= 551) {
      for (int j = V[i].a; j <= n; j += V[i].b) ans[V[i].i] += w[j];
    } else {
      if (i == 0 || V[i - 1].b != V[i].b)
        for (int j = n; j > 0; --j)
          dp[j] = (j + V[i].b > n ? 0 : dp[j + V[i].b]) + w[j];
      ans[V[i].i] = dp[V[i].a];
    }
  }
  for (int i = 0; i < t; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
