#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long ans[300009], dp[300009];
vector<pair<int, int> > adj[555];
int a, p, arr[300009];
long long rec(int x, int y) {
  if (x > a) return 0LL;
  long long& ret = dp[x];
  if (~ret) return ret;
  ret = 0;
  return ret = arr[x] + rec(x + y, y);
}
int main() {
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) scanf("%d", arr + i);
  int SQ = sqrt(a);
  scanf("%d", &p);
  for (int i = 1; i <= p; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (y > SQ) {
      for (int j = x; j <= a; j += y) ans[i] += arr[j];
      continue;
    }
    adj[y].push_back(make_pair(x, i));
  }
  for (int i = 1; i <= SQ; i++) {
    for (int j = a; j >= 1; j--) {
      dp[j] = arr[j];
      if (j + i <= a) dp[j] += dp[j + i];
    }
    for (typeof((adj[i]).begin()) it = (adj[i]).begin(); it != (adj[i]).end();
         it++)
      ans[it->second] = dp[it->first];
  }
  for (int i = 1; i <= p; i++) printf("%lld\n", ans[i]);
  return 0;
}
