N=int(raw_input()) S=raw_input() if N==1 or S=="01" or S=="10" or S=="101" or S=="010": print "NO" else: print "YES"