#include <bits/stdc++.h>
using namespace std;
long long a[300010];
pair<long long, pair<long long, long long> > lr[300010];
long long dp[300010], ans[300010];
int main() {
  long long n, i, sum = 0, j;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  long long q;
  cin >> q;
  for (i = 1; i <= q; i++)
    cin >> lr[i].second.first >> lr[i].first, lr[i].second.second = i;
  sort(lr + 1, lr + 1 + q);
  for (i = 1; i <= q; i++) {
    sum = 0;
    long long l = lr[i].first, r = lr[i].second.first,
              nom = lr[i].second.second;
    if (l <= sqrt(n)) {
      if (lr[i].first != lr[i - 1].first) {
        for (j = n - l + 1; j <= n; j++) dp[j] = a[j];
        for (j = n - l; j >= 1; j--) dp[j] = dp[j + l] + a[j];
      }
      ans[nom] = dp[r];
    } else {
      for (j = r; j <= n; j += l) sum += a[j];
      ans[nom] = sum;
    }
  }
  for (i = 1; i <= q; i++) cout << ans[i] << '\n';
}
