# coding: utf-8 # Your code here! T=int(input()) for _ in range(T): N=int(input()) A=list(map(int,input().split())) dic={0:0,1:0,2:0} for a in A: dic[a]+=1 if dic[2]==dic[0] and dic[0]>0 and dic[1]>0: print("Yes") else: print("No")