#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
vector<int> ps;
bool np[5000001];
void init(const int n) {
for (int i = 2; i <= n; ++i) {
if (!np[i]) {
ps.push_back(i);
}
for (const int pj: ps) {
if (i * pj > n) {
break;
}
np[i * pj] = true;
if (i % pj == 0) {
break;
}
}
}
}
void Main() {
int n;
cin >> n;
vector<int> a(n);
int lmt = 0;
for (auto &x: a) {
cin >> x;
}
if (n == 1) {
cout << "yEs" << endl;
} else if (n == 2 && a[0] != a[1]) {
cout << "nO" << endl;
} else {
//
}
}
#define CP_MULTI_TEST_CASES
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
init(5000001);
int t = 1;
#ifdef CP_MULTI_TEST_CASES
cin >> t;
#endif
while (t--) {
Main();
}
return cout << flush, fflush(stdout), 0;
}