// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector; using vvl = vector; using P = pair; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 void solve(){ int n; cin >> n; vl a(n); rep(i,n) cin >> a[i]; if (a[0] != a[n-1]) {cout << "Yes" << endl; return;} rep(i,n-1){ if (a[i] != a[0] && a[i] == a[i+1]){ cout << "Yes" << endl; return; } } cout << "No" << endl; } signed main(){ int t; cin >> t; while(t--){ solve(); } }