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