#include <bits/stdc++.h>
char St[25], *Tp = St;
inline void Out(long long x) {
  do *Tp++ = x % 10 ^ 48;
  while (x /= 10);
  do putchar(*--Tp);
  while (Tp != St);
  putchar('\n');
}
int n, m, k, a[300005];
int x[300005], v[300005];
long long s[300005], Ans[300005];
std::vector<int> q[555];
int main() {
  scanf("%d", &n), k = (int)ceil(sqrt(n));
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  scanf("%d", &m);
  for (int i = 1, y; i <= m; ++i) {
    scanf("%d%d", &x[i], &y);
    if (y <= k)
      q[y].push_back(i);
    else
      for (int j = x[i]; j <= n; j += y) Ans[i] += a[j];
  }
  for (int i = 1; i <= k; ++i)
    if (!q[i].empty()) {
      for (int j = n; j >= 1; --j)
        if (j + i > n)
          s[j] = a[j];
        else
          s[j] = a[j] + s[j + i];
      for (int j = 0; j < (int)q[i].size(); ++j) Ans[q[i][j]] = s[x[q[i][j]]];
    }
  for (int i = 1; i <= m; ++i) Out(Ans[i]);
  return 0;
}
