N = int(input()) S = input() if S in ['0', '1', '01', '10', '010', '101']: print('NO') else: print('YES')