n = int(input()) s = input() ans = "YES" if s in ["0","1","01","10"]: ans = "NO" print(ans)