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