#include <iostream>
using namespace std;
long long n, a[1001], d, e, f;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
d++;
if (a[i] == 0) {
break;
}
}
if (d % 2 == 0) {
cout << "YES";
} else {
for (int i = n - 1; i >= 0; i--) {
e++;
if (a[i] == 0) {
break;
}
}
if (e % 2 == 0) {
cout << "YES";
} else {
cout << "NO";
}
}
return 0;
}