#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 100;
const int inf_int = 1e9 + 100;
const long long inf_ll = 1e18;
const double PI = 3.1415926535898;
bool debug = 0;
long long dp[MAXN];
int a[MAXN];
long long ans[MAXN];
bool has[1000];
void solve() {
  int n;
  cin >> n;
  int block = 400;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int m;
  cin >> m;
  vector<pair<int, int> > c;
  for (int j = 0; j < m; ++j) {
    int x, y;
    cin >> x >> y;
    if (y > block) {
      for (int i = x; i <= n; i = i + y) {
        ans[j] += a[i];
      }
    } else {
      has[y] = 1;
    }
    c.push_back({x, y});
  }
  for (int val = 1; val <= block; ++val) {
    if (!has[val]) {
      continue;
    }
    for (int i = n; i >= 1; --i) {
      dp[i] = a[i];
      if (i + val <= n) dp[i] += dp[i + val];
    }
    for (int e = 0; e < m; ++e) {
      if (c[e].second == val) {
        ans[e] = dp[c[e].first];
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
