#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; /*-------------------------------------------------*/ vector sieve_of_eratosthenes(int num) { vector res(num + 1, true); if (num >= 0) { res[0] = false; if (num >= 1) res[1] = false; } for (int i = 2; i * i <= num; ++i) if (res[i]) { for (int j = i * i; j <= num; j += i) res[j] = false; } return res; } vector > prime_factorization(long long val) { vector > res; for (long long i = 2; i * i <= val; ++i) { if (val % i != 0) continue; int exponent = 0; while (val % i == 0) { ++exponent; val /= i; } res.emplace_back(i, exponent); } if (val != 1) res.emplace_back(val, 1); return res; } signed main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int n; cin >> n; vector sieve = sieve_of_eratosthenes(2000); vector primes; FOR(i, 1, 2001) { if (sieve[i]) primes.emplace_back(i); } int sz = primes.size(); map mp; REP(i, sz) mp[primes[i]] = i; vector > a(sz, vector(n + 1, 0)); vector zero(n + 1, 0); REP(i, n) { REP(j, sz) a[j][i + 1] = a[j][i]; zero[i + 1] = zero[i]; int ai; cin >> ai; if (ai == 0) { ++zero[i + 1]; } else { auto p = prime_factorization(ai); for (auto pr : p) { a[mp[pr.first]][i + 1] += pr.second; } } } int q; cin >> q; while (q--) { int p, l, r; cin >> p >> l >> r; --l; --r; auto factor = prime_factorization(p); bool ok = true; if (zero[r + 1] - zero[l] > 0) { ok = false; } else { for (auto pr : factor) { if (pr.first > 2000) { ok = false; break; } if (a[mp[pr.first]][r + 1] - a[mp[pr.first]][l] < pr.second) { ok = false; break; } } } cout << (ok ? "Yes\n" : "NO\n"); } return 0; }