#include <bits/stdc++.h>
using namespace std;
using VP = vector<pair<long long, long long> >;
using VVP = vector<VP>;
using VI = vector<long long>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const long long INF = 1LL << 61;
const long long mod = 1e9 + 7;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j;
  int n;
  cin >> n;
  if (n % 3 != 0) {
    int a;
    cin >> a;
    bool ng = 0;
    for (i = 1; i < n; i++) {
      int b;
      cin >> b;
      if (a != b) ng = 1;
    }
    if (ng)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  } else {
    map<int, int> ma;
    for (i = 0; i < n; i++) {
      int a;
      cin >> a;
      ma[a]++;
    }
    bool ng = 0;
    for (auto it = ma.begin(); it != ma.end(); ++it) {
      if (it->second != n / 3 && it->second != n) ng = 1;
    }
    if (ng)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}
