#include #include using namespace std; using namespace atcoder; using ll = long long; using P = pair; using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) vector Sieve(int n) { vector lst(n + 1, 1); vector temp; for (int i = 2; i <= n; i++) { if (lst[i]) { for (int j = 2 * i; j <= n; j += i) { lst[j] = 0; } } } for (int i = 2; i <= n; i++){ if (lst[i]){ temp.push_back(i); } } return temp; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int N; cin >> N; vector A(N); rep(i, N) cin >> A[i]; vector Prime = Sieve(2000); int M = (int)Prime.size(); vector> D(M, vector(N, 0)); vector> Dc(M, vector(N + 1, 0)); rep(i, M){ rep(j, N){ while (A[j] % Prime[i] == 0){ A[j] /= Prime[i]; D[i][j]++; } } rep(j, N){ Dc[i][j + 1] = Dc[i][j] + D[i][j]; } } int Q; cin >> Q; rep(_, Q){ int P, L, R; int flag = 1; cin >> P >> L >> R; L--; rep(i, M){ int cnt = 0; if (P == 1){ cout << "Yes" << "\n"; flag = 0; break; } while (P % Prime[i] == 0){ cnt++; P /= Prime[i]; } if (cnt == 0){ continue; } if (cnt > Dc[i][R] - Dc[i][L]){ cout << "NO" << "\n"; flag = 0; break; } } if (flag){ if (P == 1){ cout << "Yes" << "\n"; } else{ cout << "NO" << "\n"; } } } }