n = int(input()) s = input() if '00' in s or '11' in s: print('YES') elif s > 3: print('YES') else: print('NO')