import re input() ss=input() if re.search(r'00|11|0101|1010', ss[0:4])!=None: print('YES') else: print('NO')