#include <bits/stdc++.h>
using namespace std;
int n;
int w[310000];
long long res[310000];
int c = 580;
int p;
long long s[310000];
vector<pair<int, int> > v[600];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &w[i]);
  }
  cin >> p;
  c = sqrt(0.0 + n) + 1;
  for (int i = 0; i < p; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    if (b > c) {
      res[i] = 0;
      for (int j = a; j < n; j += b) {
        res[i] += w[j];
      }
    } else {
      v[b].push_back(make_pair(a, i));
    }
  }
  for (int b = 1; b <= c; ++b) {
    if (v[b].size() > 0) {
      memset(s, 0, sizeof(s));
      for (int j = n - 1; j >= 0; j--) {
        s[j] = w[j] + s[j + b];
      }
      for (int j = 0; j < v[b].size(); ++j) {
        res[v[b][j].second] = s[v[b][j].first];
      }
    }
  }
  for (int i = 0; i < p; ++i) {
    printf("%I64d\n", res[i]);
  }
}
