N = int(input()) X = sorted(map(int, input().split())) L = [X[i+1] - X[i] for i in range(N-1)] print(['NO', 'YES'][len(L) == 1 and L[0] != 0])