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