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