#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 ; } } int cnt = 0; for (int i = 0; i < n; i++){ if (a[0] != a[i]) cnt++; } cout << (cnt >= 4 ? "Yes" : "No") << endl; } int main(){ int t; cin >> t; while (t--){ solve(); } }