for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = [A[0]] for i in range(1, n): if A[i] == A[i - 1]: continue B.append(A[i]) if B[0] == 1: print("Yes") else: if len(B) % 2 == 0: print("Yes") else: print("No")