#include <bits/stdc++.h>
const int N = 3.1e5 + 5, M = 2333;
using namespace std;
struct node {
  int t, h;
};
vector<node> t[M];
long long f[N], da[N];
int v[N];
inline int r() {
  char h = getchar();
  int y = 0;
  while (h < '0' || h > '9') h = getchar();
  while (h >= '0' && h <= '9') y = y * 10 + h - '0', h = getchar();
  return y;
}
signed main() {
  int n = r(), p = sqrt(n);
  for (int i = 1; i <= n; i++) v[i] = r();
  int m = r();
  for (int j = 1; j <= m; j++) {
    int a = r(), b = r();
    if (b <= p)
      t[b].push_back((node){a, j});
    else {
      long long ans = 0;
      for (int i = a; i <= n; i += b) ans += v[i];
      da[j] = ans;
    }
  }
  for (int i = 1; i <= p; i++)
    if (t[i].size()) {
      for (int j = n; j; j--) f[j] = f[j + i] + v[j];
      for (int j = 0; j < (int)t[i].size(); j++) da[t[i][j].h] = f[t[i][j].t];
    }
  for (int i = 1; i <= m; i++) printf("%lld\n", da[i]);
}
