/*
Name : Mohit Khare
B.Tech 2nd Year
Computer Science and Engineering
MNNIT Allahabad
*/
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i > (int)(b); i--)
#define ll long long int
#define ull unsigned long long int
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	ll arr[n],sum=0,diff[n];
	memset(diff,0,sizeof(diff));
	for(int i = 0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	int mid = (n/2+n%2-1);
	ll avg = sum/n;
	sort(arr,arr+n);
	int f=0;
	for(int i = 0;i<n;i++)
	{
		diff[i] = abs(avg- arr[i]);
	}
	for(int i = 1;i<n;i++)
	{

		if((diff[i]==diff[i-1]) || diff[i]==0 || diff[i-1]==0)
		continue;
		else
		{
		f=1;
		break;
		}
	}
	if(f==0)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


/*
Name : Mohit Khare
B.Tech 2nd Year
Computer Science and Engineering
MNNIT Allahabad
*/
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i > (int)(b); i--)
#define ll long long int
#define ull unsigned long long int
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	ll arr[n],sum=0,diff[n];
	memset(diff,0,sizeof(diff));
	for(int i = 0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	int mid = (n/2+n%2-1);
	ll avg = sum/n;
	sort(arr,arr+n);
	int f=0;
	for(int i = 0;i<n;i++)
	{
		diff[i] = abs(arr[mid] - arr[i]);
	}
	for(int i = 1;i<n;i++)
	{

		if((diff[i]==diff[i-1]) || diff[i]==0 )
		continue;
		else if((diff[i]!=diff[i-1]))
		{
			if(i<n-1 && diff[i]==diff[i+1])
				continue;
			else f=1;
		}
		else
		{
		f=1;
		break;
		}
	}
	if(f==0)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


/*
Name : Mohit Khare
B.Tech 2nd Year
Computer Science and Engineering
MNNIT Allahabad
*/
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i > (int)(b); i--)
#define ll long long int
#define ull unsigned long long int
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	ll arr[n],sumr=0,suml=0;
	for(int i = 0;i<n;i++)
	cin>>arr[i];
	sort(arr,arr+n);
	ll a=arr[0],b,c;
	ll hash[3];
	hash[0]=10000000000,hash[1]=10000000000,hash[2]=10000000000;
	hash[0]=arr[0];
	int f=0;
	for(int i = 1;i<n;i++)
	{
		if(hash[0]==arr[i]) continue;
		else if(hash[1]==10000000000)
		{
			hash[1]=arr[i];
		}
		else if(hash[1]==arr[i]) continue;
		else if(hash[2]==10000000000)
			hash[2]=arr[i];
		else if(hash[i]==arr[i])
			continue;
		else
			f=1;
	}
	for(int i = 0;i<n;i++)
	{
	}
	sort(hash,hash+3);
	if(f==1)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	if(hash[2]==10000000000)
		cout<<"YES"<<endl;
	else if(hash[1]==10000000000)
		cout<<"YES"<<endl;
	else if((abs(hash[0]-hash[1]))==(abs(hash[1]-hash[2])))
		cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	LL sum = 0;
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum%n) {
		return false;
	}
	sum /= n;
	sort(A,A+n);
	n = unique(A,A+n)-A;
	if (n==1) return true;
	if (n==2) {
		return (sum*2 == A[0]+A[1]);
	}
	if (n==3) {
		return sum==A[1] && sum*2==A[0]+A[2];
	}
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
	}
	sort(A,A+n);
	n = unique(A,A+n)-A;

	if (n>3) return false;
	else if (n==1)
		return true;
	else if (n==2)
		return true;
	else if (n==3)
		return A[1]*2==A[0]+A[2];
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	LL sum = 0;
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum%n) {
		return false;
	}
	sum /= n;
	sort(A,A+n);
	n = unique(A,A+n)-A;
	if (n==1) {
		return true;
	}
	if (n!=3 || A[1]!=sum || A[2]-A[1]!=A[1]-A[0]) return false;
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	LL sum = 0;
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum%n) {
		return false;
	}
	sum /= n;
	sort(A,A+n);
	n = unique(A,A+n)-A;
	if (n==1) return false;
	if (n!=3 || A[1]!=sum || A[2]-A[1]!=A[1]-A[0]) return false;
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

void solve() {
	LL sum = 0,t;
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> t;
		sum += t;
	}
	if (sum%n==0) {
		cout << "YES";
	} else {
		cout << "NO";
	}
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	LL sum = 0;
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum%n) {
		return false;
	}
	sum /= n;
	sort(A,A+n);
	n = unique(A,A+n)-A;
	if (n==1) return true;
	if (n==2) {
		return (sum*2 == A[0]+A[1]);
	}
	if (n==3) {
		return sum==A[1] && sum*2==A[0]+A[2];
	}
	return false;
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include <bits/stdc++.h>

#define _for(i,a,b) for (int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
template<typename T> vector<T> &operator += (vector<T> &v, T x) {v.push_back(x);return v;}

typedef pair<int,int> P;
const int N = 1e5+5;
int A[N],n;

bool solve() {
	int n;
	cin >> n;
	_for(i,0,n) {
		cin >> A[i];
	}
	sort(A,A+n);
	n = unique(A,A+n)-A;
	if (n==1) return true;
	if (n==2) {
		return (A[0]+A[1])%2==0;
	}
	if (n==3) {
		return A[1]*2==A[0]+A[2];
	}
	return false;
}

int main(){
	#if NGOBACH
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (solve()) {
    	cout << "YES";
	} else {
		cout << "NO";
	}
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a,b,i,j=1;
int main()
{
vector<long>v; vector<long>vec;
cin>>n;  cin>>i; b=i; v.push_back(i);
for(i=0;i<n;i++)
{
	cin>>i;
	v.push_back(i);
	if(n>1)
	{
		a=i;
		if(a!=b)  j++;
	}
}
if(j<3) cout<<"YES"<<endl;
else if(j>3) cout<<"NO"<<endl;
else
{
sort(v.begin(),v.end())
for(i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	vec.push_back(v[i]);
}
if(v[3]-v[2]==v[1]) cout<<"YES"<<endl;
else  cout<<"NO"<<endl;
}
return 0;
}


#include<iostream>
using namespace std;
int l1,l2,r1,r2,k,a,b,ans;
int main()
{
cin>>l1>>r1>>l2>>r2>>k;
a=max(l1,l2);
b=min(r1,r2);

if(a<=b)
{
ans=b-a+1;
if(a<=k && k<=b) ans--;
cout<<ans<<endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a,b,i,j,n;
vector<long>v; vector<long>vec;
int main()
{
cin>>n;
for(i=0;i<n;i++)
{
	cin>>j;
	v.push_back(j);
}
j=1;
sort(v.begin(),v.end());
for(i=1;i<n;i++)
{
	if(v[i]!=v[i-1]) j++;
}
if(j<3) cout<<"YES"<<endl;
else if(j>3) cout<<"NO"<<endl;
else
{
	vec.push_back(v[0]);
for(i=1;i<n;i++)
{
	if(v[i]!=v[i-1])
	vec.push_back(v[i]);
}
if((vec[2]+vec[0])==2*vec[1]) cout<<"YES"<<endl;
else  cout<<"NO"<<endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a,b,i,j=1,n;
int main()
{
vector<long>v; vector<long>vec;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>i;
	v.push_back(i);
}
b=v[1];
for(i=1;i<n;i++)
{
		a=v[i];
		if(a!=b)  j++;
}
if(j<3) cout<<"YES"<<endl;
else if(j>3) cout<<"NO"<<endl;
else
{
sort(v.begin(),v.end());
for(i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	vec.push_back(v[i]);
}
if(v[3]-v[2]==v[1]) cout<<"YES"<<endl;
else  cout<<"NO"<<endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a,b,i,j=1,n;
int main()
{
vector<long>v; vector<long>vec;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>i;
	v.push_back(i);
}
sort(v.begin(),v.end());
for(i=1;i<n;i++)
{
	if(v[i]!=v[i+1]) j++;
}
if(j<3) cout<<"YES"<<endl;
else if(j>3) cout<<"NO"<<endl;
else
{
for(i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	vec.push_back(v[i]);
}
if(v[3]-v[2]==v[1]) cout<<"YES"<<endl;
else  cout<<"NO"<<endl;
}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a,b,i,j=1,n;
int main()
{
vector<long>v; vector<long>vec;
cin>>n;  cin>>i; b=i; v.push_back(i);
for(i=0;i<n;i++)
{
	cin>>i;
	v.push_back(i);
	if(n>1)
	{
		a=i;
		if(a!=b)  j++;
	}
}
if(j<3) cout<<"YES"<<endl;
else if(j>3) cout<<"NO"<<endl;
else
{
sort(v.begin(),v.end());
for(i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	vec.push_back(v[i]);
}
if(v[3]-v[2]==v[1]) cout<<"YES"<<endl;
else  cout<<"NO"<<endl;
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	vector<int> a(n);
	set<int> ss;
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
		ss.insert(a[i]);
	}
	if(ss.size() <= 2) {
		cout << "YES";
		return 0;
	}
	sort(all(a));
	int m = a[(n-1)/2];
	set<int> ms;
	for(int i = 0; i < n; i++) {
		if(a[i] == m) continue;
		ms.insert(abs(a[i] - m));
	}
	cout << (ms.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	if(n == 2) {
		cout << "YES";
		return 0;
	}
	int a[n];
	ldb mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
	}
	mean /= n;
	int m = round(mean);
	set<int> ms;
	for(int i = 0; i < n; i++) {
		if(a[i] == m) {
			continue;
		}
		ms.insert(abs(a[i] - m));
	}
	cout << (ms.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	if(n <= 2) {
		cout << "YES";
		return 0;
	}
	int a[n];
	ldb mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
	}
	mean /= n;
	int m = floor(mean);
	int m1 = ceil(mean);
	set<int> ms;
	set<int> ms1;
	for(int i = 0; i < n; i++) {

		if(a[i] != m) ms.insert(abs(a[i] - m));
		if(a[i] != m1) ms1.insert(abs(a[i] - m1));
	}
	cout << (ms.size() <= 1 || ms1.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	int a[n];
	ldb mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
	}
	mean /= n;
	int m = round(mean);
	set<int> ms;
	for(int i = 0; i < n; i++) {
		if(a[i] == m) {
			continue;
		}
		ms.insert(abs(a[i] - m));
	}
	cout << (ms.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	vector<int> a(n);
	set<int> ss;
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
		ss.insert(a[i]);
	}
	if(ss.size() <= 2) {
		cout << "YES";
		return 0;
	}
	ll m = (ll) floor((ldb) mean / n);
	ll m1 = (ll) ceil((ldb) mean / n);
	set<ll> ms;
	set<ll> ms1;
	for(int i = 0; i < n; i++) {

		if(a[i] != m) ms.insert(abs(a[i] - m));
		if(a[i] != m1) ms1.insert(abs(a[i] - m1));
	}
	cout << (ms.size() <= 1 || ms1.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	vector<int> a(n);
	cin >> n;
	set<int> ss;
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
		ss.insert(a[i]);
	}
	if(ss.size() <= 2) {
		cout << "YES";
		return 0;
	}
	ll m = (ll) floor((ldb) mean / n);
	ll m1 = (ll) ceil((ldb) mean / n);
	set<ll> ms;
	set<ll> ms1;
	for(int i = 0; i < n; i++) {

		if(a[i] != m) ms.insert(abs(a[i] - m));
		if(a[i] != m1) ms1.insert(abs(a[i] - m1));
	}
	cout << (ms.size() <= 1 || ms1.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	vector<int> a(n;
	cin >> n;
	set<int> ss;
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
		ss.insert(a[i]);
	}
	if(ss.size() <= 2) {
		cout << "YES";
		return 0;
	}
	ll m = (ll) floor((ldb) mean / n);
	ll m1 = (ll) ceil((ldb) mean / n);
	set<ll> ms;
	set<ll> ms1;
	for(int i = 0; i < n; i++) {

		if(a[i] != m) ms.insert(abs(a[i] - m));
		if(a[i] != m1) ms1.insert(abs(a[i] - m1));
	}
	cout << (ms.size() <= 1 || ms1.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	if(n <= 2) {
		cout << "YES";
		return 0;
	}
	int a[n];
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
	}
	ll m = (ll) floor((ldb) mean / n);
	ll m1 = (ll) ceil((ldb) mean / n);
	set<ll> ms;
	set<ll> ms1;
	for(int i = 0; i < n; i++) {

		if(a[i] != m) ms.insert(abs(a[i] - m));
		if(a[i] != m1) ms1.insert(abs(a[i] - m1));
	}
	cout << (ms.size() <= 1 || ms1.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	int a[n];
	ldb mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
	}
	mean /= n;
	int m = round(mean);
	set<int> ms;
	for(int i = 0; i < n; i++) {
		if(a[i] == m) {
			continue;
		}
		ms.insert(abs(a[i] - m));
	}
	cout << (ms.size() == 1 ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ldb;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	vector<int> a(n);
	set<int> ss;
	ll mean = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mean += a[i];
		ss.insert(a[i]);
	}
	if(ss.size() <= 2) {
		cout << "YES";
		return 0;
	}
	int mx = 0, mn = 1e9;
	for(int i = 0; i < n; i++) {
		mx = max(a[i], mx);
		mn = min(a[i], mn);
	}
	if((mx + mn) & 1) {
		cout << "NO";
		return 0;
	}
	int m = (mx + mn) / 2;
	set<int> ms;
	for(int i = 0; i < n; i++) {
		if(a[i] == m) continue;
		ms.insert(abs(a[i] - m));
	}
	cout << (ms.size() <= 1 ? "YES" : "NO");

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::set<long long int > s;
	std::vector<long long int > d;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
	if(s.size() == 3)
	{
		std::copy(s.begin(), s.end(), std::back_inserter(d));
        if ((d[1] - d[0]) + d[1] == d[2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
	}
	if(s.size() == 2)
	{
		std::set<long long int>::iterator it = s.begin();
		std::advance(it, 0);
		a = *it;
		std::advance(it, 1);
		b = *it;
		if(b%a==0 || a%b==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()==1)
		cout<<"YES"<<endl;
	if(s.size()>3)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	long long int n=0,temp=0,c1=0,c2=0;
	std::vector<long long int > s;
	std::vector<long long int > v;
	long long int hash[1000000];
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		v.push_back(temp);
		hash[temp] = hash[temp]+1;
	}
	sort(v.begin(),v.end());
	for (int i = 0; i < n; ++i)
	{
		if(hash[i] > 0)
			s.push_back(temp);
	}
	if(s.size() == 3)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::vector<long long int > v;
	std::set<long long int > s;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
	if(s.size() == 3 || s.size()==1)
		cout<<"YES"<<endl;
	if(s.size() == 2)
	{
		std::set<long long int>::iterator it = s.begin();
		std::advance(it, 0);
		a = *it;
		std::advance(it, 1);
		b = *it;
		if(a-b==a || b-a==a || a-b==b || b-a==a)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()>3)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	int n=0,temp=0,a=0,b=0;
	std::set<int > s;
	std::vector< int > d;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
	if(s.size() > 3)
   		 cout << "NO"<<endl;
    else
    {
    	if(s.size() == 3)
		{
	 	 	vector<int> vv(s.begin() , s.end());
	  		if( vv[2]-vv[1] == vv[1] - vv[0])
	    		cout << "YES"<<endl;
	  		else
	   		     cout << "NO"<<endl;
		}
      	else
      	    cout << "YES"<<endl;
    }
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::vector<long long int > s;
	std::vector<long long int > v;
	long long int hash[1000000];
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		v.push_back(temp);
		hash[temp]++;
	}
	sort(v.begin(),v.end());
	for (int i = 0; i <= n; ++i)
	{
		if(hash[i] > 0)
			s.push_back(i);
	}
	if(s.size() == 3)
		cout<<"YES"<<endl;
	if(s.size() == 2)
	{
		a = s[0];
		b=s[1];
		if(a-b==a || b-a==a || a-b==b || b-a==a)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()>3 || s.size()==1)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::vector<long long int > s;
	std::vector<long long int > v;
	long long int hash[1000000];
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		v.push_back(temp);
		hash[temp]++;
	}
	sort(v.begin(),v.end());
	for (int i = 0; i <= n; ++i)
	{
		if(hash[i] > 0)
			s.push_back(i);
	}
	if(s.size() == 3)
		cout<<"YES"<<endl;
	if(s.size() == 2)
	{
		a = s[0];
		b=s[1];
		cout<<s[0]<<"	"<<s[1]<<endl;
		if(a-b==a || b-a==a || a-b==b || b-a==a)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()>3 || s.size()==1)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::set<long long int > s;
	std::vector<long long int > d;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
	if(s.size() == 3)
	{
		std::copy(s.begin(), s.end(), std::back_inserter(d));
        if ((d[1] - d[0]) + d[1] == d[2])
            cout << "YES" << endl;
           {
            int d[3], i = 0;
            for (int x : st)
            {
                d[i] = x;
                i++;
            }
            if ((d[1] - d[0]) + d[1] == d[2])
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }
        else
            cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::set<long long int > s;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
		if(s.size() == 3)
		{
			int d[3], i = 0;
            std::set<long long int>::iterator it = s.begin();
			std::advance(it, 0);
			d[0] = *it;
			std::advance(it, 1);
			d[1] = *it;
			std::advance(it, 2);
			d[2] = *it;
            if ((d[1] - d[0]) + d[1] == d[2])
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
		}
	if(s.size() == 2)
	{
		std::set<long long int>::iterator it = s.begin();
		std::advance(it, 0);
		a = *it;
		std::advance(it, 1);
		b = *it;
		if(b%a==0 || a%b==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()==1)
		cout<<"YES"<<endl;
	if(s.size()>3)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::vector<long long int > s;
	std::vector<long long int > v;
	long long int hash[1000000];
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		v.push_back(temp);
		hash[temp]++;
	}
	sort(v.begin(),v.end());
	for (int i = 0; i <= n; ++i)
	{
		if(hash[i] > 0)
			s.push_back(i);
	}
	if(s.size() == 3 || s.size()==1)
		cout<<"YES"<<endl;
	if(s.size() == 2)
	{
		a = s[0];
		b=s[1];
		if(a-b==a || b-a==a || a-b==b || b-a==a)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()>3)
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	long long int n=0,temp=0,a=0,b=0;
	std::vector<long long int > v;
	std::set<long long int > s;
	cin>>n;
	for (long long int i = 0; i < n; ++i)
	{
		cin>>temp;
		s.insert(temp);
	}
	if(s.size() == 3 || s.size()==1)
		cout<<"YES"<<endl;
	if(s.size() == 2)
	{
		std::set<long long int>::iterator it = s.begin();
		std::advance(it, 0);
		a = *it;
		std::advance(it, 1);
		b = *it;
		if(b%a==0 || a%b==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	if(s.size()>3)
		cout<<"NO"<<endl;
	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

const int size = 100005;
set<int> si;
int n, a[size];
int mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	if(si.size() > 3){ puts("NO"); return 0; }

	if(si.size() == 1 || si.size() == 2) { puts("YES"); return 0; }

	int p;
	for ( int i = 0; i < n; i ++ ) {
		if(a[i] != mx && a[i] != mn ) {
			p = a[i];
			break;
		}
	}

	if(p-mn == mx-p) puts("YES");
	else puts("NO");

	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

const int size = 100005;
set<int> si;
int n;
int a[size];
int mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 1; i <= n; i ++ ) {
		scanf("%d", &a[i]);
		si.insert(a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
	}
	if(si.size() > 3){ puts("NO"); return 0; }

	int p = (mx-mn)/2, fg = 1;
	if((mx-mn)%2 != 0) { puts("NO"); return 0; }
	for ( int i = 1; i <= n; i ++ ) {
		if(a[i] != mx && a[i] != mn) {
			if(!(a[i] == mn+p && a[i] == mx-p)) {
				fg = 0;
				break;
			}
		}
	}
	if( fg ) puts("YES");
	else puts("NO");

	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

const int size = 100005;
set<int> si;
int n, a[size];
int mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	int p;
	for ( int i = 0; i < n; i ++ ) {
		if(a[i] != mx && a[i] != mn ) {
			p = a[i];
			break;
		}
	}

	if(mn+mx == 2*p) puts("YES");
	else puts("NO");

	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;
const int size = 100005;
set<LL> si;
LL n, a[size];
LL mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	int A = 0, B = 0, lp = 0;

	for(set<int>::iterator it = si.begin(); it != si.end(); it ++, lp++ ) {
		if(lp == 0 || lp == 2) A += *it;
		B += *it;
	}
	if(A == 2*B) puts("YES");
	else puts("NO");

	return 0;
}
// 1000000000
// 1000000000
// 1000000000


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

const int size = 100005;
set<int> si;
int n, a[size];
int mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	if(si.size() > 3){ puts("NO"); return 0; }

	int p;
	for ( int i = 0; i < n; i ++ ) {
		if(a[i] != mx && a[i] != mn ) {
			p = a[i];
			break;
		}
	}

	if(p-mn == mx-p) puts("YES");
	else puts("NO");

	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;
const int size = 100005;
set<LL> si;
LL n, a[size];
LL mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	LL A = 0, B = 0, lp = 0;

	for(set<LL>::iterator it = si.begin(); it != si.end(); it ++, lp++ ) {
		if(lp == 0 || lp == 2) A += *it;
		else B += *it;
	}
	if(A == 2*B) puts("YES");
	else puts("NO");

	return 0;
}
// 1000000000
// 1000000000
// 1000000000


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;
const int size = 100005;
set<LL> si;
LL n, a[size];
LL mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	int A = 0, B = 0, lp = 0;

	if(A == 2*B) puts("YES");
	else puts("NO");

	return 0;
}
// 1000000000
// 1000000000
// 1000000000


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;
const int size = 100005;
set<LL> si;
LL n, a[size];
LL mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	LL p;
	for ( int i = 0; i < n; i ++ ) {
		if(a[i] != mx && a[i] != mn ) {
			p = a[i];
			break;
		}
	}

	if(mn+mx == 2LL*p) puts("YES");
	else puts("NO");

	return 0;
}


#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;
const int size = 100005;
set<LL> si;
LL n, a[size];
LL mx = -1, mn = 1 << 26;

int main() {
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]); mn = min(mn, a[i]);
		si.insert(a[i]);
	}

	int sis = si.size();
	if(sis > 3){ puts("NO"); return 0; }
	if(sis == 1 || sis == 2) { puts("YES"); return 0; }

	LL A = 0, B = 0, lp = 0;

	for(set<LL>::iterator it = si.begin(); it != si.end(); it ++, lp++ ) {
		if(lp == 0 || lp == 2) A += *it;
		B += *it;
	}
	if(A == 2*B) puts("YES");
	else puts("NO");

	return 0;
}
// 1000000000
// 1000000000
// 1000000000


#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int MAXN = 100000;
int arv[MAXN + 3];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for(int i = 0; i < n; i++) cin >> arv[i];
    sort(arv, arv + n);
    int jud[MAXN + 3], len = 0;
    jud[len++] = arv[0];
    for(int i = 1; i < n; i++) if(arv[i] != arv[i - 1]) jud[len++] = arv[i];
    if(len == 1 || len == 2  || (len == 3 && jud[2] + jud[0] == jud[1] * 2) ) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==0)
			{
				if((abs(first-second))%2)
					cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(third-first)/2;

			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2==0)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(abs(third-first))/2;
			if(first>third)
			{
				int v=first;
				first=third;
				third=x;
			}
			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}

	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2==0)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(abs(third-first))/2;
			if(first>third)
			{
				int v=first;
				first=third;
				third=v;
			}
			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	long long int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}

	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	long long int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2==0)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;

			vector<ll>p (3);
			p[0]=first;
			p[1]=second;
			p[2]=third;

			sort(p.begin(),p.end());

			first=p[0];second=p[1];third=p[2];
			ll tmp=(abs(first-third))/2;
			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2==0)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(third-first)/2;

			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(third-first)/2;

			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	int sz=mymap.size();
	if(sz==1)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
			if(sz==2)
			{
				if((abs(first-second))%2==0)
					cout<<"YES"<<endl;
				else
				cout<<"NO"<<endl;
			return 0;
			}

		}

		if(cnt==3)
		{
			third=it->first;
			int tmp=(abs(third-first))/2;
			if(first>third)swap(first,third);
			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <utility>
#include <string>
#include <climits>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,k,x,n;
	scanf("%lld",&n);
	map<long long int, bool> mymap;
	map<long long int, bool>::iterator it;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&x);
		mymap[x]=true;
	}

	long long int sz=mymap.size();
	if(sz==1 || sz==2)
	{
		cout<<"YES"<<endl;
		return 0;
	}

	if(sz>3)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	long long int cnt=0,second=0,first=0,third=0;
	for(it=mymap.begin();it!=mymap.end();it++)
	{
		cnt++;
		if(cnt==1)
			first=it->first;
		if(cnt==2)
		{
			second = it->first;
		}

		if(cnt==3)
		{
			third=it->first;

			vector<ll>p (3);
			p[0]=first;
			p[1]=second;
			p[2]=third;

			sort(p.begin(),p.end());

			first=p[0];second=p[1];third=p[2];
			ll tmp=(abs(first-third))/2;
			if(first+tmp==third-tmp && first+tmp==second)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}

	}

return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&semua[banyak-1]!=1&&semua[0]!=0)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;

	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
int jenis = unique(semua.begin(), semua.end()) - semua.begin();

	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
		return 0;
	}
	if(jenis==2)
	{
		cout<<"YES";
		return 0;
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(semua.size()==2)
	{
		cout<<"YES";
		return 0;
	}
	if(mid%2==1&&mid!=3)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		mid = mid/2;
	}

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&semua[banyak-1]!=2)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

map<string,int> data;
int main() {
	int banyak;
	cin>>banyak;

	for(int i=1;i<=banyak;i++)
	{
		char query;
		string angka;
		cin>>query>>angka;
		if(query=='+')
		{
			data[angka] +=1;
		}
		else if(query=='-')
		{
			data[angka]-=1;
		}
		else
		{
			int count=0;
			for (map<string,int>::iterator it=data.begin(); it!=data.end(); ++it)
			{
					string tamp1="";
					string tamp2="";
					if(it->first.length()>angka.length())
					{
						tamp1 = it->first;
						for(int i=1;i<=it->first.length()-angka.length();i++)
						{
							tamp2+="0";
						}
						tamp2+=angka;
						bool a=true;
						for(int i=0;i<angka.length();i++)
						{
							if(tamp2[i]=='0')
							{
								if(tamp1[i]=='0'||tamp1[i]=='2'||tamp1[i]=='4'||tamp1[i]=='6'||tamp1[i]=='8')
								{

								}
								else
								{
									a=false;
									break;
								}
							}
							else if(tamp2[i]=='1')
							{
								if(tamp1[i]=='1'||tamp1[i]=='3'||tamp1[i]=='5'||tamp1[i]=='7'||tamp1[i]=='9')
								{

								}
								else
								{a=false;
									break;
								}
							}

						}
						if(a==true)
						{

							count+=it->second;
						}
					}
					else if(it->first.length()<angka.length())
					{
						tamp2=angka;
						for(int i=1;i<=angka.length()-it->first.length();i++)
						{
							tamp1+="0";
						}
						tamp1+=it->first;
						bool a=true;
						for(int i=0;i<angka.length();i++)
						{
							if(tamp2[i]=='0')
							{
								if(tamp1[i]=='0'||tamp1[i]=='2'||tamp1[i]=='4'||tamp1[i]=='6'||tamp1[i]=='8')
								{

								}
								else
								{
								a=false;
									break;
								}
							}
							else if(tamp2[i]=='1')
							{
								if(tamp1[i]=='1'||tamp1[i]=='3'||tamp1[i]=='5'||tamp1[i]=='7'||tamp1[i]=='9')
								{

								}
								else
								{
							a=false;
									break;
								}
							}

						}
						if(a==true)
						{

							count+=it->second;
						}

					}
					else
					{
						tamp2=angka;
						tamp1=it->first;
						bool a=true;
						for(int i=0;i<angka.length();i++)
						{
							if(tamp2[i]=='0')
							{
								if(tamp1[i]=='0'||tamp1[i]=='2'||tamp1[i]=='4'||tamp1[i]=='6'||tamp1[i]=='8')
								{

								}
								else
								{
									a=false;
									break;
								}
							}
							else if(tamp2[i]=='1')
							{
								if(tamp1[i]=='1'||tamp1[i]=='3'||tamp1[i]=='5'||tamp1[i]=='7'||tamp1[i]=='9')
								{

								}
								else
								{
									a=false;
									break;
								}
							}

						}
						if(a==true)
						{

							count+=it->second;
						}

					}
			}
			cout<<count<<endl;

		}

	}

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	map <int,int> test;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
		test[i]++;
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(test.size()==2)
	{
		cout<<"YES";
		return 0;
	}
	if(mid%2==1)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&mid!=1)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]-semua[0]);
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1)
	{
	    cout<<"NO";
	    return 0;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <int> semua;
	int banyak;
	cin>>banyak;
	for(int i=1;i<=banyak;i++)
	{
		int tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	int mid = (semua[banyak-1]-semua[0]);
	for(int i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;

	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&semua[0]!=1&&semua[banyak-1]!=2)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		mid = mid/2;
	}

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;

	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0])/2;

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <int> semua;
	int banyak;
	cin>>banyak;
	for(int i=1;i<=banyak;i++)
	{
		int tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	int mid = (semua[banyak-1]-semua[0])/2;
	for(int i=0;i<banyak;i++)
	{
		if(semua[i]!=mid||semua[i]!=semua[0]||semua[i]!=semua[banyak-1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0])/2;
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&semua[banyak-1]!=2&&semua[0]!=1)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <int> semua;
	int banyak;
	cin>>banyak;
	for(int i=1;i<=banyak;i++)
	{
		int tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	int mid = (semua[banyak-1]-semua[0]);
	for(int i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <int> semua;
	int a;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		int tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[a-1])
	{
		cout<<"YES";
	}
	else
	{
		bool bisa=true;
	int mid =  semua[a-1]-semua[0];
	mid  =  mid/2;
	int harus = semua[0]+mid;
	for(int i=0;i<a;i++)
	{
		if(semua[i]<harus)
		{
			if(semua[i]+mid!=harus)
			{
				bisa=false;
				break;
			}
		}
		else if(semua[i]>harus)
		{
			if(semua[i]-mid!=harus)
			{
				bisa=false;
				break;
			}
		}
	}
	if (bisa==true)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	}

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	int jenis
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
	int jenis  = distinc_abs(semua);

	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	if(jenis==2)
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(semua.size()==2)
	{
		cout<<"YES";
		return 0;
	}
	if(mid%2==1&&mid!=3)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		mid = mid/2;
	}

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;

	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1||semua[0]!=1&&semua[banyak-1]!=2)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		mid = mid/2;
	}

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;
	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);
	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(semua.size()==2)
	{
		cout<<"YES";
		return 0;
	}
	if(mid%2==1)
	{
	    cout<<"NO";
	    return 0;
	}
	else
	{
	    mid=mid/2;
	}
	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int gcd (int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
	vector <long long> semua;
	long long banyak;
	cin>>banyak;

	for(long long i=1;i<=banyak;i++)
	{
		long long tamp;
		cin>>tamp;
		semua.push_back(tamp);

	}
	sort(semua.begin(),semua.end());
	if(semua[0]==semua[banyak-1])
	{
		cout<<"YES";
	}
	else
	{
	long long mid = (semua[banyak-1]+semua[0]);
	if(mid%2==1&&mid!=3)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		mid = mid/2;
	}

	for(long long i=0;i<banyak;i++)
	{
		if(semua[i]==mid||semua[i]==semua[0]||semua[i]==semua[banyak-1])
		{

		}
		else
		{

			cout<<"NO";
			return 0;

		}
	}
	cout<<"YES";
	}
}


#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
const ll INF = 1e18;
int n, m, v[N], k, num, ru[N];
ll dis[N];
struct node
{
    ll to;
    ll w;
} now;
struct P
{
    ll u, w;
} p[N];
vector<node> g[N];

void add(int x, int y, ll z)
{
    now.to = y;
    now.w = z;
    g[x].push_back(now);
}

void solve()
{
    queue<int> q;
    for (int i = 1; i <= n; i++)
        dis[i] = INF, ru[i] = 1;
    dis[1] = 0;
    ru[1] = 1;
    v[1] = 1;
    q.push(1);
    while (!q.empty())
    {
        int x = q.front();
        q.pop();
        for (int i = 0; i < g[x].size(); i++)
        {
            now = g[x][i];
            if (dis[now.to] == dis[x] + now.w)
            {
                ru[now.to]++;
            }
            if (dis[now.to] > dis[x] + now.w)
            {
                ru[now.to] = 1;
                dis[now.to] = dis[x] + now.w;
                if (!v[now.to])
                {
                    v[now.to] = 1;
                    q.push(now.to);
                }
            }
        }
    }
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= m; i++)
    {
        ll x, y, z;
        scanf("%lld%lld%lld", &x, &y, &z);
        add(x, y, z);
        add(y, x, z);
    }

    //cout << dis[3] << endl;
    for (int i = 1; i <= k; i++)
    {
        int u, w;
        scanf("%lld%lld", &p[i].u, &p[i].w);
        add(1, p[i].u, p[i].w);
        add(p[i].u, 1, p[i].w);
    }
    solve();
    for (int i = 1; i <= k; i++)
    {
        if (dis[p[i].u] < p[i].w)
            num++;
        else if (dis[p[i].u] == p[i].w && ru[p[i].u] >= 2)
        {
            num++;
            ru[p[i].u]--;
        }
    }
    cout << num << endl;
}