using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static int N = int.Parse(Console.ReadLine()); static string S = Console.ReadLine(); static void Main() { if (N == 1) Console.WriteLine("NO"); else if (N == 2) { if (S == "00" || S == "11") Console.WriteLine("YES"); else Console.WriteLine("NO"); } else if (N == 3) { if (S == "101" || S == "010") Console.WriteLine("NO"); else Console.WriteLine("YES"); } else Console.WriteLine("YES"); } }