#include using namespace std; typedef long long ll; typedef pair lpair; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x,y) cout << (x) << " " << (y) << endl; #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];}; int sum[100010][310] = {}; ll is_zero[100010] = {}; struct Integer{ public: Integer(ll n){ } ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} //最大公約数 ll lcm(ll a,ll b){return a / gcd(a, b) * b;} //最小公倍数 bool isPrime(ll x){ if(x < 2) return false; if(x == 2) return true; if(x % 2 == 0) return false; for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false; return true; } vector divisor(ll M){ //約数の全列挙 vector dd; for(ll i = 1; i * i <= M; i++){ if(M % i == 0){ dd.push_back(i); if(i * i != M){ dd.push_back(M / i); } } } sort(dd.begin(), dd.end()); return dd; } vector factor(ll M){ //素因数分解 vector dd; if(M == 1){ dd.push_back(1); return dd; } for(ll i = 2; i*i <= M; i++){ while(M % i == 0){ dd.push_back(i); M /= i; } } if(M != 1) dd.push_back(M); sort(dd.begin(), dd.end()); return dd; } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll A[100010]; rep(i,0,N) cin >> A[i]; ll Q; cin >> Q; ll P[100010], L[100010], R[100010]; rep(i,0,Q){ cin >> P[i] >> L[i] >> R[i]; L[i]--; R[i]--; } Integer it(0); vector prime; // prime.push_back(1); rep(i,2,2001){ if(it.isPrime(i)) prime.push_back(i); } map idx; rep(i,0,prime.size()){ idx[prime[i]] = i; } rep(i,0,N){ if(A[i] == 1 || A[i] == 0) continue; vector dd = it.factor(A[i]); rep(j,0,dd.size()){ // print(dd[j]); sum[i+1][idx[dd[j]]]++; } } rep(j,0,310){ rep(i,0,N+1){ sum[i+1][j] += sum[i][j]; } } rep(i,0,N){ if(A[i] == 0) is_zero[i+1]++; } rep(i,0,N) is_zero[i+1] += is_zero[i]; // print(sum[3][0] - sum[0][0]); // print(sum[N][0]); // print(idx[2]); // print(idx[3]); rep(q,0,Q){ vector p = it.factor(P[q]); if(P[q] == 1){ print("Yes"); continue; } ll tt = is_zero[R[q]+1] - is_zero[L[q]]; if(tt > 0){ print("Yes"); continue; } map mp; rep(i,0,p.size()){ mp[p[i]]++; } bool ok = true; bool is_big = false; rep(i,0,prime.size()){ ll cnt = sum[R[q]+1][i] - sum[L[q]][i]; ll cnt2 = 0; ll tmp = P[q]; while(tmp % prime[i] == 0){ cnt2++; tmp /= prime[i]; } if(cnt2 == 0) continue; if(cnt2 > cnt){ ok = false; } } if(ok){ print("Yes"); }else{ print("NO"); } } }