T = int(input()) for _ in range(T): N = int(input()) A = "".join(input().split()) cnt1 = A.count("1") cnt0 = A.count("0") if cnt1 > cnt0: if cnt1 - cnt0 <= A.count("11"): print("Yes") else: print("No") elif cnt1 < cnt0: if cnt0 - cnt1 <= A.count("00"): print("Yes") else: print("No") else: print("Yes")