#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio();
  cin.tie();
  cout.tie();
  int n;
  cin >> n;
  int weight[n];
  for (int i = 0; i < n; ++i) cin >> weight[i];
  int p;
  cin >> p;
  vector<pair<pair<int, int>, int> > data;
  for (int i = 0; i < p; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    data.push_back({{b, a}, i});
  }
  sort(data.begin(), data.end());
  vector<pair<int, long long> > answer;
  long long dp[n];
  int prev = -1;
  for (int i = 0; i < p; ++i) {
    int b = data[i].first.first, a = data[i].first.second;
    if (b >= 500) {
      long long sum = 0;
      for (; a < n; a += b) sum += weight[a];
      answer.push_back({data[i].second, sum});
      prev = -1;
      continue;
    }
    if (prev == -1 || b != prev) {
      for (int j = n - 1; j >= 0; --j) {
        if (j + b > n - 1)
          dp[j] = weight[j];
        else
          dp[j] = weight[j] + dp[j + b];
      }
    }
    answer.push_back({data[i].second, dp[a]});
    prev = b;
  }
  sort(answer.begin(), answer.end());
  for (int i = 0; i < p; ++i) cout << answer[i].second << "\n";
  return 0;
}
