n, z = io.read("*n", "*l") s = io.read() if(4 <= n) then print("YES") elseif(n == 1) then print("NO") elseif(n == 2) then if(s == "00" or s == "11") then print("YES") else print("NO") end else if(s == "101" or s == "010") then print("NO") else print("YES") end end