#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define up(i,j,k,l) for(int i=j;i<=k;i+=l)
#define down(i,j,k,l) for(int i=j;i>=k;i-=l)
using namespace std;
const int N=5e5+10;
const int X=1e8+10;
const int P=4e6+10;
const int A=1e8;
int n;
int a[N];
int l;
int p[P];
bitset<X> x;
bool f;
void s()
{
p[1]=2;
x[1]=0;
int cnt=1;
up(i,2,A,1){
if(!x[i]){
p[++cnt]=i;
}
for(int j=1;j<=cnt && i*p[j]<=A;j++){
x[i*p[j]]=1;
if(i%p[j]==0){
break;
}
}
}
}
void solve()
{
cin>>n;
up(i,1,n,1){
cin>>a[i];
if(i==1){
l=a[i];
}
else{
l=__gcd(l,a[i]);
}
}
if(n==2){
cout<<"Yes";
}
else if(l!=1){
cout<<"No";
}
else{
map<int,int> mp;
up(i,1,n,1){
for(int j=1;p[j]*p[j]<=a[i];j++){
if(a[i]%p[j]==0){
if(mp[p[j]]){
cout<<"No"<<endl;
return;
}
else{
mp[p[j]]=1;
while(a[i]%p[j]==0){
a[i]/=p[j];
}
}
}
}
if(a[i]!=1){
if(mp[a[i]]){
cout<<"No"<<endl;
return;
}
else{
mp[a[i]]=1;
}
}
}
cout<<"Yes";
}
cout<<endl;
return;
}
int main()
{
int _=1;
s();
cin>>_;
while(_--){
solve();
}
return 0;
}