n=int(input()) a=list(int(i) for i in input().split()) count=0 a=a.sort() d=a[1]-a[0] for i in range(len(a)-1): if a[i+1]-a[i]!=d: count+=1 break if count==0: print('YES') else: print('NO')