T = gets.to_i ans = [] T.times do n = gets.to_i a = gets.split.map { |e| e.to_i } ones = 0 zeros = 0 prev = 1 a.each do |x| if x == 0 zeros += 1 if prev != 0 else ones += 1 end prev = x end ans << (zeros <= ones && zeros != 0 ? "Yes" : "No") end puts ans.join("\n")