#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> num;
  long long num0 = 0, num1 = 0, num2 = 0;
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
  }
  num.push_back(a[0]);
  if (N % 3 != 0) {
    for (long long i = 0; i < N; i++) {
      if (a[i] != 0) {
        cout << "No" << endl;
        return 0;
      }
      cout << "Yes" << endl;
      return 0;
    }
  } else {
    for (long long i = 0; i < N; i++) {
      if (a[i] == num[0]) {
        num0++;
      } else {
        if (num.size() <= 1) {
          num.push_back(a[i]);
        }
        if (a[i] == num[1]) {
          num1++;
        } else {
          if (num.size() <= 2) {
            num.push_back(a[i]);
          }
          if (a[i] == num[2]) {
            num2++;
          }
        }
      }
    }
    if (num0 == N / 3 && num1 == N / 3 && num2 == N / 3) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
