N, S = 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")