N=int(input()) S=input().rstrip() if "00" in S or "11" in S: print("YES") else: print("NO")