from collections import Counter n = int(input()) c = Counter([input() for _ in range(n)]) m = c.most_common()[0][1] print("YES" if m <= n - 1 and n - m >= m - 1 else "NO")