#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10, maxsq = 550;
int n, m, w[maxn], a[maxn], b[maxn], sq;
long long dp[maxn], ans[maxn];
vector<int> v[maxn];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  sq = sqrt(n);
  for (int i = 0; i < n; i++) cin >> w[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    if (b[i] < sq)
      v[b[i]].push_back(i);
    else
      for (int j = a[i]; j < n; j += b[i]) ans[i] += w[j];
  }
  for (int i = 0; i < sq; i++) {
    if (!v[i].size()) continue;
    for (int j = n - 1; j >= 0; j--) dp[j] = w[j] + (j + i < n ? dp[i + j] : 0);
    for (auto cur : v[i]) ans[cur] = dp[a[cur]];
  }
  for (int i = 0; i < m; i++) cout << ans[i] << "\n";
}
