# coding: utf-8 #yuki_290 n=int(raw_input()) s=raw_input() if s=="010" or s=="101" or s=="10" or s=="01" or s=="1" or s=="0": print "NO" else: print "YES"