def main(): n = input() s = input() print("NO" if s in ["0", "1", "01", "10", "010", "101"] else "YES") if __name__ == '__main__': main()