import java.util.Scanner object Main290 { def main(args: Array[String]) { val sc = new Scanner(System.in) val n = sc.nextInt val s = sc.next val res = s match{ case ss if ss.length>=4 => "YES" case ss if ss.contains("00") ||ss.contains("11") => "YES" case _ => "NO" } println(res) } }