#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvi = vector; using vvl = vector; const ll INF = 1LL << 60; const ll MOD = 1000000007; template bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } template void primeFactors(T a, map &facs) { double sqrtA = sqrt(a); for (int i = 2; i <= sqrtA + 1e-10; ++i) { while (a % i == 0) { facs[i]++; a /= i; } } if (a > sqrtA) facs[a]++; return; } int main() { int n; cin >> n; vi a(n); map facs; for (int i = 0; i < n; ++i) { cin >> a[i]; primeFactors(a[i], facs); } int q; cin >> q; vi p(n), l(n), r(n); for (int i = 0; i < q; ++i) { cin >> p[i] >> l[i] >> r[i]; l[i]--; r[i]--; } vi primefacs; for (auto &mm : facs) { primefacs.push_back(mm.first); } vvi nprimefacs(n, vi(facs.size(), 0)); for (int i = 0; i < n; ++i) { map fac; primeFactors(a[i], fac); for (auto &mm : fac) { int j = lower_bound(primefacs.begin(), primefacs.end(), mm.first) - primefacs.begin(); nprimefacs[i][j] = mm.second; } } for (int i = 1; i < n; ++i) { for (int j = 0; j < facs.size(); ++j) { nprimefacs[i][j] += nprimefacs[i - 1][j]; } } for (int i = 0; i < q; ++i) { vi facsToUse(facs.size(), 0); for (int j = 0; j < facs.size(); ++j) { facsToUse[j] += nprimefacs[r[i]][j]; if (l[i] > 0) facsToUse[j] -= nprimefacs[l[i]][j]; } map pprimes; primeFactors(p[i], pprimes); bool ok = true; for (auto &pp : pprimes) { int j = lower_bound(primefacs.begin(), primefacs.end(), pp.first) - primefacs.begin(); if (j == primefacs.size() || facsToUse[j] < pp.second) { ok = false; break; } } if (ok) cout << "Yes" << "\n"; else cout << "NO" << "\n"; } return 0; }