#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); for (int i = 0; i < n; ++i) { cin >> a[i]; } 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]--; } vector> facs(n); for (int i = 0; i < n; ++i) { primeFactors(a[i], facs[i]); } for (int i = 0; i < n - 1; ++i) { for (auto &ff : facs[i]) { facs[i + 1][ff.first] += ff.second; } } for (int i = 0; i < q; ++i) { map facsToUse = facs[r[i]]; if (l[i] > 0) { for (auto &ff : facsToUse) { facsToUse[ff.first] -= facs[l[i] - 1][ff.first]; } } map pprimes; primeFactors(p[i], pprimes); bool ok = true; for (auto &pp : pprimes) { if (facsToUse[pp.first] < pp.second) { ok = false; break; } } if (ok) cout << "Yes" << "\n"; else cout << "NO" << "\n"; } return 0; }