#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
const int INF = 2e9 + 7;
const int MOD = 1e9 + 7;
const long long LINF = 1e15 + 7;
const double Pi = acos(-1.);
const double EPS = 1e-7;
int n, m, w[N], p[N];
long long ans[N];
struct Query {
  int a, b, id;
  bool operator<(const Query &p) const {
    return b < p.b || (b == p.b && a > p.a);
  }
} a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    p[i] = -1;
    scanf("%d", &w[i]);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    a[i].id = i;
    scanf("%d%d", &a[i].a, &a[i].b);
  }
  sort(a, a + m);
  for (int i = 0; i < m; ++i) {
    int x = a[i].a % a[i].b;
    if (~p[x] && a[p[x]].b == a[i].b) {
      long long ret = ans[a[p[x]].id];
      for (int j = a[i].a - 1; j < a[p[x]].a - 1; j += a[i].b) {
        ret += w[j];
      }
      ans[a[i].id] = ret;
    } else {
      long long ret = 0;
      for (int j = a[i].a - 1; j < n; j += a[i].b) {
        ret += w[j];
      }
      ans[a[i].id] = ret;
    }
    p[a[i].a % a[i].b] = i;
  }
  for (int i = 0; i < m; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
