#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a, b, c, k;
int main() {
  a = b = c = -1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    if (a == -1)
      a = k;
    else if (b == -1 && a != k)
      b = k;
    else if (c == -1 && a != k && b != k)
      c = k;
    else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
