n = int(input()) x = list(map(int, input().strip().split(' '))) x.sort() h = [] for (u, v) in zip(x[0:n-1], x[1:n]): h.append(v - u) h.sort() if h[0] > 0 and h[0] == h[len(h) - 1]: print('YES') else: print('NO')