n=int(input()) s=input() if s=="0" or s=="1" or s=="01" or s=="10" or s=="010" or s=="101":print("NO") else:print("YES")