#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
struct P {
  int a, b;
  int lab;
  long long ans;
  bool operator<(const P &p) const {
    return b < p.b || (b == p.b && a % b < p.a % b) ||
           (b == p.b && a % b == p.a % b && a > p.a);
  }
  bool operator==(const P &p) const { return b == p.b && a % b == p.a % b; }
  bool operator!=(const P &p) const { return !operator==(p); }
  void read(int lb) {
    scanf("%d%d", &a, &b);
    lab = lb;
  }
} p[MAXN];
int num[MAXN];
int n, m;
bool cmp(const P &p0, const P &p1) { return p0.lab < p1.lab; }
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", num + i);
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) p[i].read(i);
}
void solve() {
  sort(p, p + m);
  long long ans;
  for (int pos, i = 0; i < m; ++i) {
    if (i == 0 || p[i - 1] != p[i]) {
      ans = 0;
      pos = n / p[i].b * p[i].b + p[i].a % p[i].b;
      if (pos > n) pos -= p[i].b;
    }
    for (; p[i].a <= pos; pos -= p[i].b) ans += num[pos];
    p[i].ans = ans;
  }
  sort(p, p + m, cmp);
  for (int i = 0; i < m; ++i) printf("%I64d\n", p[i].ans);
}
int main() {
  init();
  solve();
  return 0;
}
