#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, id;
} q[300005];
bool cmp(node tx, node ty) { return tx.y > ty.y; }
int n, m, blk;
long long a[300005], f[555][555], ans[300005];
int main() {
  int x, y;
  scanf("%d", &n);
  blk = sqrt(n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d %d", &q[i].y, &q[i].x), q[i].id = i;
  sort(q + 1, q + m + 1, cmp);
  q[0].y = n + 1;
  for (int i = 1; i <= m; i++) {
    x = q[i].x, y = q[i].y;
    for (int j = q[i - 1].y - 1; j >= y; j--)
      for (int k = 1; k <= blk; k++) f[k][j % k] += a[j];
    if (x <= blk)
      ans[q[i].id] = f[x][y % x];
    else
      for (int j = y; j <= n; j += x) ans[q[i].id] += a[j];
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
