#include <bits/stdc++.h>
const long double PI(acosl(-1.0));
using namespace std;
const int N = 300100, B = 555;
struct q {
  int a, b, i;
  q() {}
  const bool operator<(const q &a) const { return b < a.b; }
};
long long v[N], a[N], dp[N];
q x[N];
int main() {
  cout.precision(10);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(unsigned(time(nullptr)));
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> v[i];
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x[i].a >> x[i].b;
    x[i].a--;
    x[i].i = i;
  }
  sort(x, x + m);
  long long cur = -1;
  for (int i = 0; i < m; ++i) {
    if (x[i].b > B) {
      long long ans = 0;
      for (int j = x[i].a; j < n; j += x[i].b) {
        ans += v[j];
      }
      a[x[i].i] = ans;
      continue;
    }
    if (x[i].b != cur) {
      cur = x[i].b;
      for (int j = n - 1; j >= 0; --j) {
        if (j + cur >= n)
          dp[j] = v[j];
        else
          dp[j] = dp[j + cur] + v[j];
      }
    }
    a[x[i].i] = dp[x[i].a];
  }
  for (int i = 0; i < m; ++i) cout << a[i] << '\n';
}
