#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9 + 7;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> v(n, 0);
  map<int, int> mii;
  for (int i = 0; i < (n); i++) {
    cin >> v[i];
    mii[i]++;
  }
  if (mii.size() > 3) {
    cout << "No" << endl;
    return 0;
  }
  if (mii.size() == 3) {
    if (n % 3 == 0) {
      bool ok = 1;
      for (auto u : mii) {
        if (u.second != n / 3) ok = 0;
      }
      if (ok)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  if (mii.size() == 2) {
    bool ok = 1;
    for (auto u : mii) {
      if (u.second != n / 3 && u.second != 2 * n / 3) ok = 0;
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
  }
  if (mii.size() == 1) {
    bool ok = 1;
    for (auto u : mii) {
      if (u.first != 1) ok = 0;
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
  }
  return 0;
}
