N = gets.to_i S = gets.chomp() ans = if N >= 3 or S == "00" or S == "11" "YES" else "NO" end puts ans