#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 10, M = 400;
long long int n, a[N], k, dp[M][N], tt;
int32_t main() {
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i * i <= n; i++) {
    dp[i][0] = 0;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j * j <= n; j++) {
      dp[j][i] = a[i - 1];
      dp[j][i] += (i > j ? dp[j][i - j] : 0);
    }
  }
  cin >> tt;
  while (tt--) {
    long long int l, d;
    cin >> l >> d;
    if (d * d <= n) {
      cout << dp[d][l + ((n - l) / d) * d] - dp[d][max(l - d, 0ll)] << endl;
      continue;
    }
    long long int sum = 0;
    for (long long int i = l; i <= n; i += d) {
      sum += a[i - 1];
    }
    cout << sum << endl;
  }
  return 0;
}
