n = int(input()) s = input() if n == 1: print("NO") elif n == 2: if s[0] == 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")