#include using namespace std; vector> factorize(int n){ vector> fs; int k = 0; for (; n % 2 == 0; n /= 2, ++k); if (k > 0) fs.emplace_back(2, k); for (int p = 3; p * p <= n; p += 2){ k = 0; for(; n % p == 0; n /= p, ++k); if (k > 0) fs.emplace_back(p, k); } if (n > 1) fs.emplace_back(n, 1); return fs; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector As(N, 0); for (auto & a : As) cin >> a; vector> cum(2001, vector(1, 0)); vector> idx(2001, vector(1, 0)); for (int i = 0; i < N; ++i){ int a = As[i]; if (a == 0){ cum[0].push_back(cum[0].back() + 1); idx[0].push_back(i + 1); continue; }else if (a == 1){ continue; } auto factors = factorize(a); for (auto pk : factors){ auto p = pk.first; auto k = pk.second; cum[p].push_back(cum[p].back() + k); idx[p].push_back(i + 1); } } int Q; cin >> Q; int P, L, R; while (Q--){ cin >> P >> L >> R; auto itR = upper_bound(idx[0].begin(), idx[0].end(), R); auto itL = upper_bound(idx[0].begin(), idx[0].end(), L - 1); --itR; --itL; if (cum[0][itR - idx[0].begin()] > cum[0][itL - idx[0].begin()]){ cout << "Yes\n"; continue; } else if (P == 1){ cout << "Yes\n"; continue; } auto factors = factorize(P); bool flag = true; for (auto pk : factors){ auto p = pk.first; auto k = pk.second; if (p > 2000){ flag = false; break; } auto itR = upper_bound(idx[p].begin(), idx[p].end(), R); auto itL = upper_bound(idx[p].begin(), idx[p].end(), L - 1); --itR; --itL; if (cum[p][itR - idx[p].begin()] - cum[p][itL - idx[p].begin()] < k){ flag = false; break; } } if (flag){ cout << "Yes\n"; }else{ cout << "NO\n"; } } return 0; }