N = int(input()) ans = True S = list(map(int, input().split())) S.sort() d = S[1] - S[0] for i in range(1, N - 1): if d != S[i + 1] - S[i]: ans = False break if ans and d != 0: print("YES") else: print("NO")