import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); String S = scan.next(); scan.close(); if(N == 1) { System.out.println("NO"); }else if(N == 2) { if(S.equals("01") || S.equals("10")) { System.out.println("NO"); }else { System.out.println("YES"); } }else if(N == 3) { if(S.equals("010") || S.equals("101")) { System.out.println("NO"); }else { System.out.println("YES"); } }else { System.out.println("YES"); } } }