n = gets.to_i s = gets.chomp if(n > 3) puts "YES" exit end if s =~ /(00)|(11)/ puts "YES" else puts "NO" end