class Yukicoder def initialize n = gets.chomp.to_i s = gets.chomp good = %w(00 11 000 001 011 100 110 111) if n >= 4 || good.include?(s) puts "YES" else puts "NO" end end end Yukicoder.new