#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void swap(int &a, int &b) {
  int t = a;
  a = b;
  b = t;
}
int a[310000];
const int R = 600;
vector<pair<int, int> > b[600];
long long int dp[310000];
long long int ans[310000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%d", &a[i]);
  }
  int q, l, r;
  scanf("%d", &q);
  for (int i = (0); i < (q); i++) {
    scanf("%d", &l);
    scanf("%d", &r);
    l--;
    if (r < R) {
      b[r].push_back(make_pair(l, i));
    } else {
      ans[i] = 0;
      for (int j = l; j < n; j += r) {
        ans[i] += a[j];
      }
    }
  }
  for (int i = (0); i < (R); i++) {
    sort(b[i].begin(), b[i].end());
    memset(dp, 0, sizeof(dp));
    for (int j = n - 1; j >= 0; j--) {
      dp[j] = a[j];
      if (j + i < n) {
        dp[j] += dp[j + i];
      }
    }
    for (int j = (0); j < (b[i].size()); j++) {
      ans[b[i][j].second] = dp[b[i][j].first];
    }
  }
  for (int i = (0); i < (q); i++) cout << ans[i] << endl;
  return 0;
}
