#include #define int long long using namespace std; using ll = long long; void solve(); template void println(Args... args) { apply([](auto &&... args) { ((cout << args << ' '), ...); }, tuple(args...)); cout << '\n'; } int32_t main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int t = 1; cin >> t; for (int tc = 0; tc < t; ++tc) { solve(); } return 0; } void solve() { int n; cin >> n; vector a(n); for (int &x : a) cin >> x; if (a.front() != a.back()) return println("Yes"); auto b = a; b.erase(unique(b.begin(), b.end()), b.end()); if (b.size() >= 9) return println("Yes"); int x = a.front(); for (int i = 0; i + 1 < n; ++i) if (a[i] != x && a[i + 1] != x) return println("Yes"); println("No"); }