#include using namespace std; void solve() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i ++) cin >> a[i]; vector> b; bool flag = false; for (int i = 0, j; i < n; i = j + 1) { j = i; while (j + 1 < n && a[j + 1] == a[i]) ++ j; b.push_back({ a[i], (j - i + 1) > 1 }); if (j - i + 1 > 1) flag = true; } if (b.size() % 2 == 0) { cout << "Yes\n"; } else { if (flag) cout << "Yes\n"; else cout << "No\n"; } } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int tt; cin >> tt; while (tt --) solve(); return 0; }