#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T& x, T y) {
  return x > y ? x = y, true : false;
}
template <class T>
inline bool chkmax(T& x, T y) {
  return x < y ? x = y, true : false;
}
template <class T>
T reads() {
  T x = 0;
  static int f;
  static char c;
  for (f = 1; !isdigit(c = getchar());)
    if (c == '-') f = -1;
  for (x = 0; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return x * f;
}
pair<int, pair<int, int> > V[300005];
int n, m, p, pp, cnt, rm, a[300005];
long long f[22][305555];
long long ans, ans1[300005];
int main(void) {
  n = reads<int>();
  for (int i = 1; i <= n; ++i) a[i] = reads<int>();
  m = reads<int>();
  for (int i = 1; i <= m; ++i) {
    p = reads<int>();
    pp = reads<int>();
    ans = 0;
    if (pp > 500) {
      for (int j = p; j <= n; j += pp) ans += a[j];
      ans1[i] = ans;
    } else
      V[++cnt] = make_pair(pp, make_pair(p, i));
  }
  sort(V + 1, V + 1 + m);
  rm = m;
  for (int i = 1; i <= 25; ++i) {
    for (int j = 1; j <= 20; ++j)
      for (int z = n; z >= 1; --z) f[j][z] = a[z] + f[j][z + (i - 1) * 20 + j];
    for (int j = 1; j <= m; ++j)
      if (V[j].first <= i * 20 && V[j].first > i * 20 - 20 &&
          ans1[V[j].second.second] == 0) {
        if (V[j].first % 20 != 0)
          ans1[V[j].second.second] = f[V[j].first % 20][V[j].second.first];
        else
          ans1[V[j].second.second] = f[20][V[j].second.first];
        rm--;
      }
    if (rm == 0) break;
  }
  for (int i = 1; i <= m; ++i) printf("%lld\n", (ans1[i]));
  return 0;
}
