input() print("YES" if "00" in (S := input()) or "11" in S or S.count("01") >= 2 or S.count("10") >= 2 else "NO")