#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
void Free_palestine() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int arr[MAXN];

signed main(){
  Free_palestine();
  int n; cin>>n;
  
  
  for(int i = 0; i < n; i++){
    cin>>arr[i];
  }
  
  int left = 0;
    int right = n - 1;
    bool is_palindrome = true;

    while (left < right) {
        if (arr[left] != arr[right]) {
            is_palindrome = false;
            break; 
        }
        left++;
        right--;
    }

    if (is_palindrome) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}