n = int(input()) x = list(map(int,input().split())) x_so = sorted(x) che = [] for i in range(1, n): che.append(x_so[i] - x_so[i - 1]) che_set = set(che) if (len(che_set) == 1) and che_set != 0: print('YES') else: print('NO')