T=int(input()) for t in range(T): N=int(input()) A=list(map(int,input().split())) if A[0]: for i in range(N): A[i]^=1 if A[-1]: ans="Yes" else: if any(A[i] and A[i+1] for i in range(N-1)) or sum(A)>=4: ans="Yes" else: ans="No" print(ans)