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