#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; bool IsPrime[MAX]; ll MinFactor[MAX]; vector preprocess(ll n = MAX) { vector res; for (ll i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1; IsPrime[0] = false; IsPrime[1] = false; MinFactor[0] = 0; MinFactor[1] = 1; for (ll i = 2; i < n; ++i) { if (IsPrime[i]) { MinFactor[i] = i; res.push_back(i); for (ll j = i * 2; j < n; j += i) { IsPrime[j] = false; if (MinFactor[j] == -1) MinFactor[j] = i; } } } return res; } vector > fast_prime_factor(ll n) { vector > res; while (n != 1) { ll prime = MinFactor[n]; ll exp = 0; while (MinFactor[n] == prime) { ++exp; n /= prime; } res.push_back(make_pair(prime, exp)); } return res; } ll cnv[2001]; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ preprocess(); vector pr; { ll idx = 0; for (ll i = 2; i <= 2000; i++) { if (IsPrime[i]) { pr.push_back(i); cnv[i] = idx++; } } } ll n; scanf("%lld", &n); vector a(n); for (ll i = 0; i < n; i++) scanf("%lld", &a[i]); vector> psum(n + 1, vector(pr.size() + 1)); vector z(n + 1); for (ll i = 0; i < n; i++) { if (a[i] == 0) z[i + 1] = z[i] + 1; else { if (a[i] == 1) continue; vector> vp = fast_prime_factor(a[i]); for (auto p : vp) { psum[i + 1][cnv[p.first]] += p.second; } for (ll j = 0; j < psum[i].size(); j++) { psum[i + 1][j] += psum[i][j]; } } } ll Q; scanf("%lld", &Q); while (Q--) { ll x, l, r; scanf("%lld %lld %lld", &x, &l, &r); if (z[r] - z[l - 1] > 0) puts("Yes"); else { vector> vp = fast_prime_factor(x); if (x == 1) puts("Yes"); else { bool flag = true; for (auto p : vp) { ll cnt = psum[r][cnv[p.first]] - psum[l - 1][cnv[p.first]]; if (cnt < p.second) flag = false; } if (flag) puts("Yes"); else puts("NO"); } } } return 0; }