n = int(input()) s = input() if n >= 4: print('YES') else: if 2 <= n <= 3: print(['NO', 'YES']['00' in s or '11' in s]) else: print('NO')