#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin>>n;

	vector<int> sieve(1e6+1,0);

	unordered_map<int,vector<int>> comp;
	for(int i=2; i<=1e6; i++){
		if(sieve[i]==0){
			for(int j=i; j<=1e6; j+=i) sieve[j]=i;
		}
	}


	for(int i=1; i<=n; i++){
		int x;

		cin>>x;

		while(x>1){
			int c=sieve[x];
			x/=c;
			comp[c].push_back(i);
		}
	}


	int q;
	cin>>q;

	for(int i=0; i<q; i++){
		int l,r,k;
		cin>>l>>r>>k;

		bool good=1;

		map<int,int> m;
		while(k>1){
			int c=sieve[k];
			k/=c;
			m[c]++;
		}
		for(auto i:m) if(i.second>upper_bound(comp[i.first].begin(), comp[i.first].end(), r)-lower_bound(comp[i.first].begin(), comp[i.first].end(),l)) good=0;
		if(good) cout<<"Yes\n";
		else cout<<"No\n";
	}

}
