#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; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int ncase; scanf("%d", &ncase); while (ncase--) { vector v; int n; scanf("%d", &n); while (n--) { int x; scanf("%d", &x); if (v.empty() || v.back() != x) v.push_back(x); } if (v.size() % 2 == 0) { puts("Yes"); } else if (v[0] == 1) { if (v.size() <= 3) puts("No"); else puts("Yes"); } else { puts("No"); } } return 0; }