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