#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
using namespace std;
template <typename T>
void uin(T &a, T b) {
  if (b < a) {
    a = b;
  }
}
template <typename T>
void uax(T &a, T b) {
  if (b > a) {
    a = b;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> crd;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    crd.push_back(a[i]);
  }
  sort(crd.begin(), crd.end());
  crd.erase(unique(crd.begin(), crd.end()), crd.end());
  if (crd.size() > 3) {
    cout << "No\n";
    return 0;
  }
  for (long long fir : crd) {
    for (long long sec : crd) {
      for (long long thi : crd) {
        vector<long long> v;
        map<long long, long long> cnt;
        for (long long i = 0; i < n; ++i) {
          ++cnt[a[i]];
          if (i % 3 == 0) --cnt[fir];
          if (i % 3 == 1) --cnt[sec];
          if (i % 3 == 2) --cnt[thi];
        }
        bool ok = 1;
        for (auto p : cnt) {
          if (p.second) {
            ok = 0;
            break;
          }
        }
        if (ok) {
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  cout << "No\n";
  return 0;
}
