N=int(input()) X=sorted(list(map(int,input().split()))) d=X[1]-X[0] cnt=0 for i in range(1,N-1): if d!=X[i+1]-X[i] or d==0: cnt=1 print("YES" if cnt==0 else "NO")