#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 2;
const char nxtl = '\n';
const double eps = (double)1e-9;
template <typename T>
inline bool updmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int sz = 550, n, a[MAXN], p;
long long res[MAXN], dp[MAXN];
pair<pair<int, int>, int> q[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  scanf("%d", &p);
  for (int i = 1; i <= p; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    q[i] = make_pair(make_pair(y, x), i);
  }
  int lst = -1;
  sort(q + 1, q + 1 + p);
  for (int i = 1; i <= p; ++i) {
    if (q[i].first.first > sz) {
      long long sum = 0ll;
      int x = q[i].first.second;
      for (x; x <= n; x += q[i].first.first) sum += a[x];
      res[q[i].second] = sum;
    } else {
      if (lst != q[i].first.first) {
        lst = q[i].first.first;
        for (int i = n; i >= 1; --i) {
          dp[i] = a[i];
          if (i + lst <= n) dp[i] += dp[i + lst];
        }
      }
      res[q[i].second] = dp[q[i].first.second];
    }
  }
  for (int i = 1; i <= p; ++i) printf("%lld\n", res[i]);
  return 0;
}
