N=int(input()) S=input() if N==1: print("NO") elif N==2 and S[0]!=S[1]: print("NO") elif N==3 and S[0]!=S[1] and S[1]!=S[2]: print("NO") else: print("YES")