#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()) {
  return vector2<T>(n0, vector<T>(n1, e));
}
template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()) {
  return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < (n); ++i) cin >> a[i];
  if (n % 3 == 0) {
    map<long long int, long long int> m;
    for (long long int i = 0; i < (n); ++i) {
      m[a[i]]++;
    }
    for (pair<long long int, long long int> p : m) {
      if (p.second % (n / 3)) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
  for (long long int i = 0; i < (n); ++i) {
    if (a[i] != a[0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
