N=input() S=input() print('YES' if S.count('00')+S.count('11') else 'NO')