#include <bits/stdc++.h>
using namespace std;
const int maxn=1e7+14;
int a[maxn];
void solve(){
int n;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
bool ok = 1;
for (int i = 1; i <= n/2; i++){
if (a[i] != a[n - i + 1]) {
ok = 0;
break;
}
}
cout << ok;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen("input.txt","r")) {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuPTFlNysxNDsKaW50IGFbbWF4bl07CnZvaWQgc29sdmUoKXsKCWludCBuOwoJY2luID4+IG47Cglmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspewoJCWNpbiA+PiBhW2ldOwoJfQoJYm9vbCBvayA9IDE7Cglmb3IgKGludCBpID0gMTsgaSA8PSBuLzI7IGkrKyl7CgkJaWYgKGFbaV0gIT0gYVtuIC0gaSArIDFdKSB7CgkJCSBvayA9IDA7CgkJCSBicmVhazsKCQl9Cgl9CgkKCWNvdXQgPDwgb2s7Cn0KaW50IG1haW4oKXsKCWlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CgljaW4udGllKDApOyAgICBjb3V0LnRpZSgwKTsKCWlmIChmb3BlbigiaW5wdXQudHh0IiwiciIpKSB7CgkJZnJlb3BlbigiaW5wdXQudHh0IiwiciIsc3RkaW4pOwoJCWZyZW9wZW4oIm91dHB1dC50eHQiLCJ3IixzdGRvdXQpOwoJfQoJc29sdmUoKTsKCXJldHVybiAwOwp9Cg==