N = int(input()) S = [str(x) for x in input()] if N == 1: print("NO") elif N == 2: if len(set(S)) == 1: print("YES") else: print("NO") elif N == 3: if S[0] == S[1] or S[1] == S[2]: print("YES") else: print("NO") else: print("YES")