from collections import Counter from operator import itemgetter N=int(input()) C=Counter([input() for i in range(N)]) LIST=[] for c in C: LIST.append([C[c],c]) A=[] while LIST: LIST.sort(key=itemgetter(0),reverse=True) while LIST and LIST[-1][0]==0: LIST.pop() if LIST==[]: print("YES") break if A and A[-1]==LIST[0][1]: if len(LIST)==1: print("NO") break else: LIST[1][0]-=1 A.append(LIST[1][1]) else: LIST[0][0]-=1 A.append(LIST[0][1])