input() a=sorted(list(map(int,input().split()))) pre=a[1];dif=a[1]-a[0] if dif==0:print('NO');exit() for x in a[2:]: if dif==0 or x-pre!=dif: print('NO');exit() pre=x;dif=x-pre print('YES')