#include using namespace std; #define starburst ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define FOR(i, a, b) for(int i = a;i tree, int i, int j, int mod, int N) { i += N; j += N; int res = 1; while (i <= j) { if (res == 0) { return 0; } if ((i & 1) == 1) { res = (res * tree[i]) % mod; i += 1; } i >>= 1; if ((j & 1) == 0) { res = (res * tree[j]) % mod; j -= 1; } j >>= 1; } return res; } int main() { starburst int N; cin >> N; vector nums(N); vector tree(2*N); FOR(i, N, 2*N) { cin >> tree[i]; } rFOR(i, 1, N) { tree[i] = tree[i<<1] * tree[i<<1|1]; } int M; cin >> M; FOR(i, 0, M) { int a, b, c; cin >> a >> b >>c; if (query(tree, a-1, b-1, c, N) == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }