#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl "\n"
#define sz(x) x.size()
void fastio()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}
bool is_Palindrome(int arr[], int start, int end)
{
if(arr[start] != arr[end])
return false;
is_Palindrome(arr, start + 1, end - 1);
return true;
}
void solve()
{
int n; cin >> n;
int arr[n];
for(int i = 0; i < n; i++)
cin >> arr[i];
cout << ((is_Palindrome(arr, 0, n - 1)) ? "YES\n" : "NO\n");
}
int main()
{
fastio();
int test = 1;
// cin >> test;
for (int tc = 1; tc <= test; tc++)
solve();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIG5sICJcbiIKI2RlZmluZSBzeih4KSB4LnNpemUoKQoKdm9pZCBmYXN0aW8oKQp7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSwgY2luLnRpZShudWxscHRyKSwgY291dC50aWUobnVsbHB0cik7CiNpZm5kZWYgT05MSU5FX0pVREdFCglmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKSwgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKI2VuZGlmCn0KCmJvb2wgaXNfUGFsaW5kcm9tZShpbnQgYXJyW10sIGludCBzdGFydCwgaW50IGVuZCkKewoJaWYoYXJyW3N0YXJ0XSAhPSBhcnJbZW5kXSkKCQlyZXR1cm4gZmFsc2U7Cglpc19QYWxpbmRyb21lKGFyciwgc3RhcnQgKyAxLCBlbmQgLSAxKTsKCXJldHVybiB0cnVlOwp9Cgp2b2lkIHNvbHZlKCkKewoJaW50IG47IGNpbiA+PiBuOwoJaW50IGFycltuXTsKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJY2luID4+IGFycltpXTsKCWNvdXQgPDwgKChpc19QYWxpbmRyb21lKGFyciwgMCwgbiAtIDEpKSA/ICJZRVNcbiIgOiAiTk9cbiIpOwp9CgppbnQgbWFpbigpCnsKCWZhc3RpbygpOwoJaW50IHRlc3QgPSAxOwoJLy8gY2luID4+IHRlc3Q7Cglmb3IgKGludCB0YyA9IDE7IHRjIDw9IHRlc3Q7IHRjKyspCgkJc29sdmUoKTsKfQ==