#include #include #include #include #include #include #define llint long long using namespace std; llint n, Q; llint a[100005]; int d[325][100005]; int sum[325][100005]; int need[325]; bool prime[2005]; vector pvec; int main(void) { ios::sync_with_stdio(0); cin.tie(0); for(int i = 2; i < 2005; i++){ if(prime[i]) continue; for(int j = 2*i; j < 2005; j+=i) prime[j] = true; } for(int i = 2; i < 2005; i++){ if(!prime[i]) pvec.push_back(i); } int m = pvec.size(); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 0; i < m; i++){ for(int j = 1; j <= n; j++){ int t = a[j]; while(t % pvec[i] == 0){ d[i][j]++; t /= pvec[i]; } } for(int j = 1; j <= n; j++){ sum[i][j] = sum[i][j-1] + d[i][j]; } } cin >> Q; int p, l, r; for(int q = 0; q < Q; q++){ cin >> p >> l >> r; int t = p; for(int i = 0; i < m; i++) need[i] = 0; for(int i = 0; i < m; i++){ if(pvec[i] > t) break; while(t % pvec[i] == 0){ need[i]++; t /= pvec[i]; } } if(t > 1){ cout << "NO" << "\n"; continue; } bool flag = true; for(int i = 0; i < m; i++){ if(need[i] > sum[i][r]-sum[i][l-1]){ flag = false; break; } } if(flag) cout << "Yes" << "\n"; else cout << "NO" << "\n"; } flush(cout); return 0; }