#include <bits/stdc++.h>
using namespace std;
const int maxn = 300001;
const int hasl = 550;
long long dp[maxn];
pair<pair<int, int>, int> q[maxn];
int w[maxn];
long long ans[maxn];
int32_t main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d", &q[i].first.second);
    scanf("%d", &q[i].first.first);
    q[i].first.second--;
    q[i].second = i;
  }
  sort(q, q + m);
  int pas = -1;
  for (int i = 0; i < m; i++) {
    int a = q[i].first.second;
    int b = q[i].first.first;
    int id = q[i].second;
    if (b != pas and b < hasl) {
      pas = b;
      for (int i = n - 1; i >= 0; i--) {
        dp[i] = w[i];
        if (i + b < n) dp[i] += dp[i + b];
      }
    }
    if (b < hasl)
      ans[id] = dp[a];
    else
      for (int j = a; j < n; j += b) ans[id] += w[j];
  }
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
  return 0;
}
