Filya and Homework

题意翻译

### 题目描述 刺猬 Filya 今天第一次去学校,由于老师给他的作业太难所有他需要你的帮助来完成: 老师给 Filya 一个仅包含正整数的数组 $a_1, a_2, \cdots,a_n $ 首先,他选择一个整数 $x$ ,然后他将 $x$ 加到数组的某些元素上(仅有一次),再从其他一些元素中减去 $x$,(每个元素仅减一次)并留一些元素不进行操作。经过这些操作以后,他希望数组内所有的元素均相等。现在,他想知道他可不可以找到这样一个 $x$ 并进行上述操作,使数组内的每一个元素相等。 ### 输入格式 第一行包含一个整数$n$($1\le n\le10^5$)表示数组内的元素个数。 第二行包含 $n$ 个整数 $a_1, a_2, …… a_n$($0\le a_i\le 10^9$)即为数组内的元素。 ### 输出格式 输出仅为一行如果数组内的元素在经过题目内所述操作后不能全部相等,则输出 `NO` ; 否则,输出 `YES` 。 ### 说明 在第一个样例中,应该选择第一个元素作为 $x$,添加到第一个和第五个,然后从第二个和第三个减去。

题目描述

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.

输入输出格式

输入格式


The first line of the input contains an integer $ n $ ( $ 1<=n<=100000 $ ) — 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.

输出格式


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).

输入输出样例

输入样例 #1

5
1 3 3 2 1

输出样例 #1

YES

输入样例 #2

5
1 2 3 4 5

输出样例 #2

NO

说明

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.