func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int lim = 15;   int n, a[300010];   int q;   long long c[300010];   struct my {     int a, b, id;     my() {}     my(int a, int b, int id) : a(a), b(b), id(id) {}     bool operator<(const my &u) const {       if (b == u.b) return a % b < u.a % b;       return b < u.b;     }   } b[300010];   long long ans[300010];   int l;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     scanf( %d , &q);     for (int i = 0; i < q; i++) {       int w, e;       scanf( %d%d , &w, &e);       b[i] = my(w, e, i);     }     sort(b, b + q);     for (int i = 0; i < q; i++) {       if (b[i].b >= 500) {         int id = b[i].id;         for (int j = b[i].a; j <= n; j += b[i].b) ans[id] += a[j];         continue;       }       if (i == 0 || b[i].b != b[i - 1].b ||           (b[i].a % b[i].b != b[i - 1].a % b[i - 1].b)) {         l = 1;         int q = b[i].a, w = b[i].b;         int t = q % w;         if (t == 0) t = w;         for (int j = t; j <= n; j += w) c[l] = c[l - 1] + a[j], l++;         ans[b[i].id] = c[l - 1] - c[(q + w - 1) / w - 1];       } else {         int q = b[i].a, w = b[i].b;         ans[b[i].id] = c[l - 1] - c[(q + w - 1) / w - 1];       }     }     for (int i = 0; i < q; i++) printf( %I64d n , ans[i]);     return 0;   }   