#include <bits/stdc++.h>
using namespace std;
const int mt = 3 * 1e5 + 7;
inline int read() {
  int num = 0, flag = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') flag = -1;
  } while (ch < '0' || ch > '9');
  do {
    num = num * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return num * flag;
}
struct question {
  int x, y, pos;
} ques[mt];
vector<question> v[mt];
int a[mt];
long long ans[mt], dp[mt];
int main() {
  int n = read();
  int sqrtn = sqrt(n);
  for (int i = 1; i <= n; i++) a[i] = read();
  int m = read();
  for (int i = 1; i <= m; i++) {
    ques[i].x = read(), ques[i].y = read(), ques[i].pos = i;
    if (ques[i].y > sqrtn)
      for (int j = ques[i].x; j <= n; j += ques[i].y) ans[i] += a[j];
    else
      v[ques[i].y].push_back(ques[i]);
  }
  for (int i = 1; i <= sqrtn; i++) {
    if (v[i].size()) {
      for (int j = n; j >= 1; j--)
        if (j + i > n)
          dp[j] = a[j];
        else
          dp[j] = dp[j + i] + a[j];
      for (int j = 0; j < v[i].size(); j++) ans[v[i][j].pos] = dp[v[i][j].x];
    }
  }
  for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
  return 0;
}
