#include using namespace std; using ll = long long; int main(){ ll n; cin >> n; ll a[n]; vector o[1000000]; for(ll i = 0; i < n; i++){ cin >> a[i]; ll subject = a[i]; ll d = 1; while(subject > 1){ d++; if(d*d > a[i]){ d = subject; } while(subject % d == 0){ subject /= d; o[d-1].push_back(i); } } } /*for(ll i = 0; i < 1000000; i++){ if(o[i].size() == 0){ continue; } cout << i+1 << ":"; for(auto j : o[i]){ cout << " " << j; } cout << endl; }*/ ll q; cin >> q; while(q){ //cout << "query " << q << endl; q--; ll s,t,k; cin >> s >> t >> k; s--; t--; ll original_k = k; ll divisor = 1; bool ok = true; while(k > 1){ divisor++; //cout << "dividing " << k; //cout << " by " << divisor << endl; if(divisor*divisor > original_k){ divisor = k; //cout << "actually dividing by " << k << endl; } ll amount = 0; while(k%divisor == 0){ k /= divisor; amount++; } if(amount == 0){ //cout << "nothing" << endl; continue; } //cout << amount << " times" << endl; ll bfrom = 0; ll bto = o[divisor-1].size()-1; while(bfrom < bto){ ll middle = bto+bfrom; middle /= 2; if(o[divisor-1][middle] < s){ bfrom = middle+1; }else{ bto = middle; } } ll pos = bfrom; ll needed = pos + amount - 1; if(needed >= o[divisor-1].size()){ ok = false; break; } if(o[divisor-1][needed] > t){ ok = false; break; } } if(ok){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } }