n=gets.to_i;puts n>3?:YES: gets.scan(/00|11/).empty? ? :NO: :YES