#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 10;
struct node {
  int id, a, b;
  bool operator<(node c) const {
    if (b != c.b) return b < c.b;
    return a < c.a;
  }
} a[mx];
long long int ans[mx];
long long int w[mx];
long long int dp[mx];
int n, q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &w[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a[i].a, &a[i].b);
    a[i].id = i;
  }
  sort(a, a + q);
  int nowb = 0;
  int m = sqrt(n + 1);
  for (int i = 0; i < q; i++) {
    if (a[i].b >= m) {
      long long int sum = 0;
      for (int j = a[i].a; j <= n; j += a[i].b) sum += w[j];
      ans[a[i].id] = sum;
    } else {
      if (a[i].b != nowb || dp[a[i].a] == 0) {
        for (int j = n; j >= 1; j--) {
          if (j + a[i].b > n)
            dp[j] = w[j];
          else
            dp[j] = dp[j + a[i].b] + w[j];
        }
      }
      ans[a[i].id] = dp[a[i].a];
      nowb = a[i].b;
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
  return 0;
}
