n = int(input()) s = input() print("YES" if n >= 4 or "00" in s or "11" in s else "NO")