#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ULL; #define MEM(a,b) memset((a),(b),sizeof(a)) const LL INF = 1e9 + 7; const int N = 2e5 + 10; pair vp[N]; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int ncase; scanf("%d", &ncase); while (ncase--) { int n; scanf("%d", &n); vector v(n); for (auto& x : v) scanf("%d", &x); while (v.size() >= 2 && v[v.size() - 1] == v[v.size() - 2]) v.pop_back(); reverse(v.begin(), v.end()); while (v.size() >= 2 && v[v.size() - 1] == v[v.size() - 2]) v.pop_back(); int cnt = 1; for (int i = 1; i < v.size(); i++) { if (v[i] != v[i - 1]) cnt++; } if (cnt % 2 == 0 || cnt < v.size()) { puts("Yes"); } else puts("No"); } return 0; }