#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- map enumpr(int n) { map V; for (int i = 2; 1LL * i * i <= n; i++) while (n % i == 0) V[i]++, n /= i; if (n > 1) V[n]++; return V; } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, A[101010]; vector pr[201010]; int Q; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; rep(i, 0, N) { cin >> A[i]; if (A[i] == 1) continue; auto mp = enumpr(A[i]); fore(p, mp) rep(i, 0, p.second) pr[p.first].push_back(i); } rep(i, 0, 201010) pr[i].push_back(inf); cin >> Q; rep(q, 0, Q) { int P, L, R; cin >> P >> L >> R; L--; if (P == 1) { printf("Yes\n"); return; } auto mp = enumpr(P); bool ans = true; fore(p, mp) { auto ite1 = lower_bound(all(pr[p.first]), L); auto ite2 = lower_bound(all(pr[p.first]), R); int cnt = ite2 - ite1; if (cnt < p.second) { ans = false; break; } } if (ans) printf("Yes\n"); else printf("NO\n"); } }