#include <bits/stdc++.h>
using namespace std;
struct faner {
  int a, b, id;
  long long ans;
} s[300010];
int c[300010], n, m;
long long f[300010];
inline bool cmp(faner a, faner b) { return a.b < b.b; }
inline bool cmps(faner a, faner b) { return a.id < b.id; }
void work(int d) {
  for (int i = n; i; i--)
    if (i + d <= n)
      f[i] = f[i + d] + (long long)c[i];
    else
      f[i] = (long long)c[i];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &s[i].a, &s[i].b);
    s[i].id = i;
  }
  sort(s + 1, s + m + 1, cmp);
  for (int i = 1; i <= m; i++)
    if (s[i].b <= sqrt(n)) {
      if (i == 1 || s[i].b != s[i - 1].b) work(s[i].b);
      s[i].ans = f[s[i].a];
    } else {
      long long sum = 0;
      for (int j = s[i].a; j <= n; j += s[i].b) sum += (long long)c[j];
      s[i].ans = sum;
    }
  sort(s + 1, s + m + 1, cmps);
  for (int i = 1; i <= m; i++) printf("%lld\n", s[i].ans);
  return 0;
}
