N=int(input()) X=input().split(' ') Y=[] for i in range(N): Y.append(max(X)) X.remove(max(X)) d=int(Y[1])-int(Y[0]) if(d==0): print('NO') else: for i in range(1,N-1): if (d != int(Y[1])-int(Y[0])): print('NO') break if ( i == N-2 ): print('YES')