N, *X = map(int, open(0).read().split()) X.sort() d = X[1] - X[0] if d != 0 and all(b - a == d for a, b in zip(X, X[1:])): print("YES") else: print("NO")