#include <bits/stdc++.h>
using namespace std;
bool exists(int x, vector<int> &v) {
  for (int e : v) {
    if (e == x) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> kind;
  int k = 1;
  int a;
  cin >> a;
  kind.push_back(a);
  for (int i = 1; i < n; i++) {
    cin >> a;
    if (!exists(a, kind)) {
      kind.push_back(a);
      k++;
    }
    if (k > 3) {
      k = n - 1;
      break;
    }
  }
  cout << (n % k == 0 ? "Yes" : "No") << '\n';
  return 0;
}
