#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int sum[100010][330] = {}; vector p; int main() { for (int i = 2; i <= 2000; i++) { bool bo = true; for (int j = 2; j * j <= i; j++) { if (i % j == 0) { bo = false; } } if (bo) { p.emplace_back(i); } } int n; cin >> n; for (int i = 1; i <= n; i++) { int a; cin >> a; for (int j = 0; j < p.size(); j++) { if (a % p[j] == 0) { int co = 0; while (a % p[j] == 0) { a /= p[j]; co++; } sum[i][j] += co; } sum[i][j] += sum[i - 1][j]; } } int q; cin >> q; for (int i = 0; i < q; i++) { int b, l, r; cin >> b >> l >> r; bool bo = true; for (int j = 0; j < p.size(); j++) { if (b % p[j] == 0) { int co = 0; while (b % p[j] == 0) { b /= p[j]; co++; } if (sum[r][j] - sum[l - 1][j] < co) { bo = false; } } } if (b != 1) { bo = false; } if (bo) { cout << "Yes" << endl; } else { cout << "NO" << endl; } } }