#include <bits/stdc++.h>
using namespace std;
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)(1e9) + 7;
using pii = pair<long long, long long>;
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  for (long long i = (0); i < (v.size()); i++)
    for (long long j = (0); j < (v[i].size()); j++) {
      if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
        cerr << "INF";
      } else
        cerr << v[i][j];
      cerr << (j == v[i].size() - 1 ? '\n' : ' ');
    }
  cerr << endl;
}
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  long long N;
  cin >> N;
  vector<long long> a(N);
  for (long long i = (0); i < (N); i++) {
    cin >> a[i];
  }
  map<long long, long long> mp;
  for (auto x : a) {
    mp[x]++;
  }
  if (mp.size() == 1) {
    Yes(1);
  } else {
    if (mp.size() == 3) {
      vector<long long> y;
      for (auto p : mp) {
        y.emplace_back(p.second);
      }
      Yes(y[0] == y[1]);
    } else {
      Yes(0);
    }
  }
  return 0;
}
