#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 4 && a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4) {
    cout << "No" << endl;
    return 0;
  }
  bool t = true;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] != a[j]) {
        t = false;
      }
    }
  }
  if (t == false) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}
