input() s=input() print('YES' if '00' in s or '11' in s else 'NO')