#include using namespace std; using int64 = long long; const int mod = 1e9 + 7; const int64 infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 > &p) { os << p.first << " " << p.second; return os; } template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template< typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for(int i = 0; i < (int) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; } template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template< typename T = int64 > vector< T > make_v(size_t a) { return vector< T >(a); } template< typename T, typename... Ts > auto make_v(size_t a, Ts... ts) { return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...)); } template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; } template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); } template< typename F > struct FixPoint : F { FixPoint(F &&f) : F(forward< F >(f)) {} template< typename... Args > decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, forward< Args >(args)...); } }; template< typename F > inline decltype(auto) MFP(F &&f) { return FixPoint< F >{forward< F >(f)}; } std::vector< int > eratosthenes_sieve(int n) { std::vector< int > ps(n + 1); std::iota(ps.begin() + 2, ps.end(), 2); for(int i = 2; i * i <= n; ++i) if(ps[i]) for(int j = i * i; j <= n; j += i) ps[j] = 0; return ps; } std::vector< int > make_primes(int n) { std::vector< int > ps = eratosthenes_sieve(n); ps.erase(std::remove(ps.begin(), ps.end(), 0), ps.end()); return ps; } std::pair< std::vector< int64 >, std::vector< int64 > > prime_factor_decomp_fast(int64 n) { static const auto ps = make_primes(32000); // sqrt(10^9) std::vector< int64 > p, e; int64 m = n; for(auto &i : ps) { if(i * i > n) break; if(m % i != 0) continue; int c = 0; while(m % i == 0) c++, m /= i; p.push_back(i); e.push_back(c); } if(m > 1) { p.push_back(m); e.push_back(1); } return std::make_pair(p, e); } int main() { int N; cin >> N; vector< int64 > A(N); cin >> A; vector< int > zero(N + 1); auto ret = make_primes(2001); vector< int > id(2020, -1); int ptr = 0; for(auto &p : ret) id[p] = ptr++; vector< vector< int > > sum(ret.size(), vector< int >(N + 1)); for(int i = 0; i < N; i++) { if(A[i] == 0) { zero[i + 1]++; } else { auto p = prime_factor_decomp_fast(A[i]); for(int j = 0; j < p.first.size(); j++) { sum[id[p.first[j]]][i + 1] += p.second[j]; } } } for(int i = 1; i <= N; i++) { zero[i] += zero[i - 1]; } for(auto &vs : sum) { for(int i = 1; i < vs.size(); i++) vs[i] += vs[i - 1]; } int Q; cin >> Q; for(int i = 0; i < Q; i++) { int p, l, r; cin >> p >> l >> r; --l; if(p == 1 || zero[r] - zero[l]) { cout << "Yes" << endl; continue; } auto tap = prime_factor_decomp_fast(p); bool flag = true; for(int j = tap.first.size() - 1; j >= 0 && flag; j--) { if(tap.first[j] > 2000) { flag = false; } else { auto &vs = sum[id[tap.first[j]]]; flag &= vs[r] - vs[l] >= tap.second[j]; } } if(flag) cout << "Yes" << endl; else cout << "NO" << endl; } }