#include using namespace std; void solve(){ int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; if (a[0] != a[n-1]){ cout << "Yes" << endl; return ; } for (int i = 0; i < n-1; i++){ if (a[0] != a[i] && a[i] == a[i+1]){ cout << "Yes" << endl; return ; } } cout << "No" << endl; } int main(){ int t; cin >> t; while (t--){ solve(); } }