#include <bits/stdc++.h>
using namespace std;
struct pole {
  int a, b;
  long long odp;
  int nr;
};
bool porownanie1(pole a, pole b) {
  if (a.b < b.b) return true;
  if (a.b > b.b) return false;
  if (a.nr < b.nr) return true;
  return false;
}
bool porownanie2(pole a, pole b) {
  if (a.nr < b.nr) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; ++i) cin >> w[i];
  int p;
  cin >> p;
  vector<pole> a(p);
  for (int i = 0; i < p; ++i) {
    cin >> a[i].a >> a[i].b;
    --a[i].a;
    a[i].odp = 0;
    a[i].nr = i;
  }
  sort(a.begin(), a.end(), porownanie1);
  for (int le = 0; le < p;) {
    int pr = le;
    while (pr < p && a[pr].b == a[le].b) ++pr;
    --pr;
    if (a[le].b <= 540) {
      vector<long long> s(n, 0);
      for (int i = n - 1; i >= 0; --i) {
        s[i] = w[i];
        if (i + a[le].b < n) s[i] += s[i + a[le].b];
      }
      for (int i = le; i <= pr; ++i) a[i].odp = s[a[i].a];
    } else {
      for (int i = le; i <= pr; ++i)
        for (int j = a[i].a; j < n; j += a[i].b) a[i].odp += w[j];
    }
    le = pr + 1;
  }
  sort(a.begin(), a.end(), porownanie2);
  for (int i = 0; i < p; ++i) cout << a[i].odp << endl;
  return 0;
}
