N, S = int(input()), input() if N > 3: print("YES") elif N == 1: print("NO") elif N == 2: print("YES" if S[0] == S[1] else "NO") else: prnit("YES" if S[0] == S[1] or S[1] == S[2] else "NO")