#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n;     set<long long int> s;     while (n--) {       cin >> t;       s.insert(t);     }     if (s.size() >= 4)       cout <<  NO ;     else {       if (s.size() == 3) {         auto it1 = s.begin();         auto it2 = it1;         auto it3 = it2;         it2++;         it3++;         it3++;         if (2 * (*it2) == *it1 + *it3)           cout <<  YES ;         else           cout <<  NO ;       } else         cout <<  YES ;     }   }   