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