#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 <math.h>
#define lli long long int
using namespace std;
int main(){
// 1 1 2 3 3
lli n;
cin >> n;
lli a[n];
lli best = 0;
lli worst = 1e9+1;
for(int i = 0; i < n; i++){
cin >> a[i];
//best = max(best, a[i]);
//worst = min(worst, a[i]);
}
sort(a, a+n);
bool yn = true;
bool xn = true;
lli s;
s = a[n/2];
lli init = abs(a[0] - s);
for(int i = 1; i < n; i++){
if( abs(a[i] - s) == init || a[i] == s){
yn = true;
}
else{
yn = false;
break;
}
}
if(yn){
cout << "YES";
fflush(stdout);
}
else{
cout << "NO";
fflush(stdout);
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGRlcXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxiaXRzZXQ+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxmdW5jdGlvbmFsPgojaW5jbHVkZSA8bnVtZXJpYz4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxzc3RyZWFtPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxjc3RkbGliPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8bWF0aC5oPiAKI2RlZmluZSBsbGkgbG9uZyBsb25nIGludAp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50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