#include<stdio.h>
#include<stdlib.h>

#define ll long long int

int main() {
  int n;
  scanf("%d", &n);
  ll *a = malloc(sizeof(ll) * n);
  int i;
  for(i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  int b[1000000000 + 1] = {0};
  //int *b = malloc(sizeof(int) * 1000000000);
  ll c[3] = {0};
  int type = 0;
  int j = 0;
  for(i = 0; i < n; i++) {
    if(b[a[i]] == 0) {
      b[a[i]]++;
      if((j == 0)
      || (j == 1 && c[0] != a[i])
      || (j == 2 && c[0] != a[i] && c[1] != a[i])) {
        c[j] = a[i];
        j++;
      }
      type++;
    }
  }
  int ans = 1;
  if(type != 3)                                     ans = 0;
  else if(b[c[0]] != b[c[1]] || b[c[1]] != b[c[2]]) ans = 0;
  if(ans == 1) printf("Yes\n");
  else         printf("No\n");
  return 0;
}