#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 3e5, kThreshold = 547;
void solve() {
  static int a[kMaxN];
  ;
  static int64_t dp[kMaxN];
  static int64_t answers[kMaxN];
  static vector<pair<int, int> > small_q_queries[kThreshold];
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    p--;
    if (q < kThreshold)
      small_q_queries[q].push_back(make_pair(i, p));
    else {
      int64_t result = int64_t{0};
      for (int j = p; j < n; j += q) result += static_cast<int64_t>(a[j]);
      answers[i] = result;
    }
  }
  for (int q = 1; q < kThreshold; q++) {
    for (int p = n - 1; p >= 0; p--) {
      dp[p] = static_cast<int64_t>(a[p]);
      if (p + q < n) dp[p] += static_cast<int64_t>(dp[p + q]);
      if (q == 1)
        ;
    }
    for (const pair<int, int> &pii : small_q_queries[q]) {
      answers[pii.first] = dp[pii.second];
    }
  }
  for (int i = 0; i < m; i++) cout << answers[i] << "\n";
}
struct CustomStruct {
  int a = 1, b = 17;
} custom_struct;
string to_string(CustomStruct a) {
  return "{" + to_string(a.a) + ", " + to_string(a.b) + "}";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
