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