func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1, M = 1e9 + 7;   mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());   int n, q, bit[N], inv[N], a[N], last[N], INVER[N], ans[N];   bool prime[N];   vector<int> v[N];   struct query {     int l, r, id;     void sc(int temp) {       scanf( %d%d , &l, &r);       id = temp;     }   } Q[N];   int power(int base, int to) {     int ret = 1;     while (to) {       if (to & 1) ret = ret * 1LL * base % M;       to >>= 1;       base = base * 1LL * base % M;     }     return ret;   }   int INV(int a) {     if (INVER[a] != -1) return INVER[a];     return INVER[a] = power(a, M - 2);   }   void add(int at, int *bit, int val) {     for (; at < N; at += (-at) & at) bit[at] = bit[at] * 1LL * val % M;   }   int get(int at, int *bit) {     int ret = 1;     for (; at; at -= at & (-at)) ret = ret * 1LL * bit[at] % M;     return ret;   }   int main() {     for (int i = 0; i < N; i++) bit[i] = inv[i] = 1;     memset(last, -1, sizeof last);     memset(INVER, -1, sizeof INVER);     scanf( %d , &n);     for (int i = 2; i < N; i++)       if (!prime[i]) {         for (int j = i; j < N; j += i) {           prime[j] = 1;           v[j].push_back(i);         }       }     for (int i = 1; i <= n; i++) scanf( %d , a + i);     scanf( %d , &q);     for (int i = 0; i < q; i++) Q[i].sc(i);     sort(Q, Q + q, [&](query a, query b) { return a.r < b.r; });     int j = 1;     for (int i = 0; i < q; i++) {       while (j <= Q[i].r) {         add(j, bit, a[j]);         add(j, inv, INV(a[j]));         for (auto k : v[a[j]]) {           if (last[k] != -1) {             add(last[k], bit, INV(k - 1) * 1LL * k % M);             add(last[k], inv, (k - 1LL) * INV(k) % M);           }           last[k] = j;           add(last[k], bit, (k - 1LL) * INV(k) % M);           add(last[k], inv, k * 1LL * INV(k - 1) % M);         }         j++;       }       ans[Q[i].id] = get(Q[i].r, bit);       ans[Q[i].id] = ans[Q[i].id] * 1LL * get(Q[i].l - 1, inv) % M;     }     for (int i = 0; i < q; i++) printf( %d n , ans[i]);   }   