N = int(input()) S = input() import sys for i in range(len(S)-1): if S[i] == S[i+1]: print('YES') exit() if len(S) >= 4: print('YES') else: print('NO')