#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, flag;
int a[maxn];
int num[maxn];
map<int, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (mp[a[i]] == 0) {
      mp[a[i]]++;
      num[i] = a[i];
      flag++;
    }
  }
  if (flag > 3) {
    printf("No\n");
  } else if (flag == 3) {
    if (mp[a[1]] == mp[a[2]] && mp[a[2]] == mp[a[3]])
      printf("Yes\n");
    else
      printf("No\n");
  } else
    printf("No\n");
  return 0;
}
