n=int(input()) x=sorted(map(int,input().split())) for i in range(n-1): if x[i]==x[i+1] or x[1]-x[0]!=x[i+1]-x[i]: print("NO") exit() print("YES")