#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  auto a = vector<long long>(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (i >= n - 3 && a[i] == a[n + 3 - i]) count++;
    if (a[i] == a[i + 3]) count++;
  }
  if (count == a.size()) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
