n = int(input()) s = input() print('YES' if ('00' or '11' or '0101' or '1010' in s) else 'NO')