import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); final String input = sc.next(); if(n >= 4){ System.out.println("YES"); }else if(n == 1){ System.out.println("NO"); }else{ final int num = Integer.parseInt(input, 2); if(n == 3){ System.out.println(num == 2 || num == 5 ? "NO" : "YES"); }else{ System.out.println(num == 1 || num == 2 ? "NO" : "YES"); } } } }