#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, id;
} p[300005];
long long int dp[300005];
long long int f[300005];
bool cmp(node a, node b) {
  if (a.b != b.b) return a.b < b.b;
  return a.a < b.a;
}
long long int ans[300005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%I64d", &f[i]);
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p[i].a, &p[i].b);
    p[i].id = i;
  }
  sort(p + 1, p + m + 1, cmp);
  int last = 0;
  for (int i = 1; i <= m; i++) {
    if (p[i].b < 512 && last != p[i].b) {
      last = p[i].b;
      for (int j = n; j >= 1; j--) {
        dp[j] = f[j];
        if (j + p[i].b <= n) dp[j] += dp[j + p[i].b];
      }
    }
    if (p[i].b < 512)
      ans[p[i].id] = dp[p[i].a];
    else {
      ans[p[i].id] = 0;
      for (int j = p[i].a; j <= n; j += p[i].b) ans[p[i].id] += f[j];
    }
  }
  for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
}
