#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7;
string yn(bool f) { return f ? "Yes" : "No"; }
string YN(bool f) { return f ? "YES" : "NO"; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long N;
  long long maximum = 0;
  vector<long long> a;
  cin >> N;
  a.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
  }
  if (N == 4) {
    if (a[0] != a[2] || a[1] != a[3]) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  cout << "Yes"
       << "\n";
  return 0;
}
