#include <bits/stdc++.h>
template <class T>
__inline__ __attribute__((always_inline)) bool cmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
__inline__ __attribute__((always_inline)) bool cmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
using namespace std;
const int N = 1e5 + 5;
int n, a[N], b[N], cnt[5], m;
int main() {
  scanf("%d", &n);
  for (register int i = (1), I = (n) + 1; i < I; ++i)
    scanf("%d", &a[i]), b[i] = a[i];
  sort(b + 1, b + 1 + n), m = unique(b + 1, b + 1 + n) - b - 1;
  if (m == 1) return puts("Yes"), 0;
  if (m != 3) return puts("No"), 0;
  for (register int i = (1), I = (n) + 1; i < I; ++i) {
    if (a[i] == b[1]) ++cnt[1];
    if (a[i] == b[2]) ++cnt[2];
    if (a[i] == b[3]) ++cnt[3];
  }
  puts(cnt[1] == cnt[2] && cnt[2] == cnt[3] ? "Yes" : "No");
  return 0;
}
