Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.

Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then he adds x to some elements of the array (no more than once), subtract x from some other elements (also, no more than once) and do no change other elements. He wants all elements of the array to be equal.

Now he wonders if it's possible to pick such integer x and change some elements of the array using this x in order to make all elements equal.


-----Input-----

The first line of the input contains an integer n (1 ≤ n ≤ 100 000) — the number of integers in the Filya's array. The second line contains n integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — elements of the array.


-----Output-----

If it's impossible to make all elements of the array equal using the process given in the problem statement, then print "NO" (without quotes) in the only line of the output. Otherwise print "YES" (without quotes).


-----Examples-----
Input
5
1 3 3 2 1

Output
YES

Input
5
1 2 3 4 5

Output
NO



-----Note-----

In the first sample Filya should select x = 1, then add it to the first and the last elements of the array and subtract from the second and the third elements.

Difficulty: interview

Starter code:

Solutions:
read = lambda: list(map(int, input().split()))
n = int(input())
a = list(read())
s = set()
for i in a:
    s.add(i)
f1 = len(s) < 3
f2 = len(s) == 3 and max(s) + min(s) == 2 * sorted(s)[1]
print('YES' if f1 or f2 else 'NO')


n = int(input())
a = map(int, input().split())
b = set(a)
if len(b) <= 2:
	print("YES")
elif len(b) > 3:
	print("NO")
else:
	a = []
	for i in b:
		a.append(i)
	a.sort()
	if a[1] - a[0] == a[2] - a[1]:
		print("YES")
	else:
		print("NO")

n = int(input())
a = sorted(list(set(list(map(int, input().split())))))
if len((a)) < 3:
    print('YES')
elif len((a)) > 3:
    print('NO')
else:
    if a[1] - a[0] == a[2] - a[1]:
        print('YES')
    else:
        print('NO')

n=int(input())
ip=list(map(int,input().split()))
count=0
used=[]
for i in ip:
    if i not in used and count<5:
        used.append(i)
        count+=1
if count<=2:
    print('YES')
elif count>3:
    print('NO')
else:
    used=sorted(used)
    if used[1]-used[0]==used[2]-used[1]:
        print('YES')
    else:
        print('NO')


input()
a = list(map(int, input().split()))
a = sorted(set(a))

if len(a) >= 4:
    print("NO")
elif len(a) <= 2:
    print("YES")
else:
    if a[1] - a[0] == a[2] - a[1]:
        print("YES")
    else:
        print("NO")


n = int(input())
a = [int(x) for x in input().split()]

d = sorted(set(a))

if len(d) <= 2 or len(d) == 3 and d[0]+d[2] == 2*d[1]:
    print("YES")
else:
    print("NO")


3

n = int(input())
array = list(set(list(map(int, input().split()))))
array.sort()

if len(array) < 3:
    print("YES")
elif len(array) > 3 or array[1] - array[0] != array[2] - array[1]:
    print("NO")
else:
    print("YES")



n = int(input())
a = set(map(int, input().split()))
if(len(a) > 3):
    print("NO")
elif(len(a) < 3):
    print("YES")
else:
    a = list(a)
    a.sort()
    if((a[0] + a[2]) / 2 == a[1]):
        print("YES")
    else:
        print("NO")

n = int(input())
A = list(map(int, input().split()))
B = []
l = 0
for i in A:
	if i not in B:
		B.append(i)
		l += 1
	if l > 3:
		print("NO")
		return
B.sort()
if l < 3:
	print("YES")
else:
	if B[0] + B[2] == 2 * B[1]:
		print("YES")
	else:
		print("NO")


from sys import stdin

n = int(stdin.readline())

numbers = set(int(x) for x in stdin.readline().split())

if len(numbers) > 3:
    print('NO')
elif len(numbers) < 3:
    print('YES')
else:
    s = sorted(numbers)
    if s[2] - s[1] == s[1] - s[0]:
        print('YES')
    else:
        print('NO')


n = int(input())
data = list(map(int,input().split()))
nums = set(data)
if len(nums)<=2:
    print("YES")
elif len(nums)==3:
    tmp = list(sorted(list(nums)))
    if tmp[1]-tmp[0]==tmp[2]-tmp[1]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

def solve():
    input()
    a = list(map(int, input().split()))
    nums = set()
    for n in a:
        nums.add(n)

    if len(nums) <= 2:
        print('YES')
        return

    if len(nums) == 3:
        ma = max(nums)
        mi = min(nums)
        nums.remove(ma)
        nums.remove(mi)
        mid = nums.pop()
        if ma - mid == mid - mi:
            print('YES')
            return

    print('NO')


def main():
    solve()

def __starting_point():
    main()

__starting_point()

n, a = int(input()), set(map(int, input().split()))
if (len(a) <3):
    print("YES")
elif len(a) == 3:
    a = sorted(list(a))
    if a[1] - a[0] == a[2] - a[1]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

from sys import stdout
n =int(input())
s = [int(i) for i in input().split()]
a= s[0]
b = -1
c = -1
for i in s[1:]:
	if i!=a and i!=b and i!=c:
		if b <0:
			b = i
		elif c <0:
			c = i
		else:
			print("NO")
			break
else:
	if c == -1:
		print("YES")
	else:
		r = (max(a,b,c) - min(a,b,c))/2+ min(a,b,c)
		if a==r or b ==r or c == r:
			print("YES")
		else:
			print("NO")
		


n = int(input())
a = list(map(int,input().split()))

s = set()
for el in a:
    s.add(el)
    if len(s) > 3:
        break

if len(s) <= 2:
    print('YES')
elif len(s) > 3:
    print('NO')
else:
    sl = sorted(list(s))
    print('YES' if sl[0] + sl[2] == 2 * sl[1] else 'NO')


from collections import defaultdict
import sys, os, math

def __starting_point():
    #n, m = list(map(int, input().split()))
    #sys.stdout.flush()
    n = int(input())
    arr = list(map(int, input().split()))
    temp = []
    for num in arr:
        if num not in temp:
            temp.append(num)
        if len(temp) > 3:
            print("NO")
            return
    temp.sort()
    if len(temp) < 3 or temp[0] + temp[2] == 2 * temp[1]:
        print("YES")
    else:
        print("NO")

__starting_point()

temp=input()
temp=input().split()
arr=[int(k) for k in temp]

s=sorted(list(set(arr)))

if len(s)>3:
	print("NO")
elif len(s)<3:
	print("YES")
else:
	if s[2]+s[0]==2*s[1]:
		print("YES")
	else:
		print("NO")


n = int(input())
a = sorted(set(map(int, input().split())))
if len(a) > 3:
    print("NO") 
elif len(a) == 1:
    print("YES")
elif len(a) == 2:
    print('YES')
else:
    if ((a[0] + a[2]) / 2 != a[1]):
        print('NO')
    else:
        print('YES')

import sys, math
n = int(input())
z = list(map(int, input().split()))
a = max(z)
b = min(z)
y = (a + b) // 2
x1 = a - y
x2 = a - b
flag = [0, 0, 0]
for i in range(n):
    if z[i] == y:
        flag[0] += 1
    else:
        if z[i] < y and z[i] + x1 == y:
            flag[0] += 1
        else:
            if z[i] - x1 == y:
                flag[0] += 1
        if z[i] + x2 == a or z[i] == a:
            flag[1] += 1
        if z[i] - x2 == b or z[i] == b:
            flag[2] += 1
if flag.count(n) >= 1:
    print('YES')
else:
    print('NO')

N = int(input())
A = set(list(map(int, input().split())))
if len(A) == 1:
    print("YES")
elif len(A) == 2:
    print("YES")
elif len(A) == 3:
    A = list(A)
    max_v = max(A)
    min_v = min(A)
    md_v = sum(A) - max_v - min_v
    if md_v * 2 == max_v + min_v:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


n = int(input())
a = list(map(int,input().split()))
r = set(a)
if len(r)<=3:
    r = list(r)
    r.sort()
    if len(r)==1 or len(r)==2 or r[1]-r[0] == r[2]-r[1]:
        print('YES')
    else:
        print('NO')
else:
    print('NO')

n = int(input())
l = list(map(int, input().split()))
s = set()
for i in l:
    s.add(i)
l = list(s)
l.sort()
if len(l) > 3:
    print('NO')
if len(l) == 3:
    if (l[0] + l[2]) / 2 == l[1]:
        print('YES')
    else:
        print('NO')
if len(l) <= 2:
    print('YES')

import sys

n = int(input())
a = [int(x) for x in input().split()]
aa = list(set(a))
aa.sort()

if len(aa) > 3:
    print("NO")
    return
if len(aa) < 3:
    print("YES")
    return
if (aa[0] + aa[2]) % 2 != 0:
    print("NO")
    return

if 2 * aa[1] == aa[0] + aa[2]:
    print("YES")
else:
    print("NO")


#!/usr/local/env python3
# -*- encoding: utf-8 -*-
import sys


def readnlines(f_in):
    n = int(f_in.readline().strip())
    s = set()
    content = f_in.readline().strip()
    for i, line in zip(list(range(n)), content.split(' ')):
        if line.isdigit():
            s.add(int(line))
        else:
            s.add(line)
    return s


def print_args():
    print("Recieved {} arguments = {}.".format(len(sys.argv), sys.argv))


def intersect(l1, r1, l2, r2):
    left = max(l1, l2)
    right = min(r1, r2)
    return left, right, max(0, right - left + 1)


def solve():
    m = readnlines(sys.stdin)
    uniques = sorted(m) 
    #print("len(set(m)) = {}".format(len(set(m))))
    #print(uniques)
    if len(uniques) > 3:
        return "NO"
    elif len(uniques) == 3:
        if uniques[2] + uniques[0] == 2 * uniques[1]:
            return "YES"
        return "NO"
    else:
        return "YES"


def __starting_point():
   ans = solve()
   print(ans)

__starting_point()

n = int(input())
a = list(map(int, input().split()))

b = set(a)

if len(b) >= 4:
    print("NO")
else:
    x = list(b)
    x.sort()
    if len(x) == 1:
        print("YES")
    elif len(x) == 2:
        print("YES")
    else:
        if x[1] * 2 == x[0] + x[2]:
            print("YES")
        else:
            print("NO")