n=gets.to_i s=gets.chomp re=[/00/,/11/,/0101/,/1010/] puts re.any?{|r|s=~r} ? "YES" : "NO"