n = int(input()) a = list(map(int, input().split())) a.sort() q = a[1] - a[0] for i in range(2, n): p = a[i] - a[i-1] if p != q or p == 0: print("NO") break q = p else: print("YES")