1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 typedef double db; 5 #define INF 0x3f3f3f3f 6 #define _for(i,a,b) for(int i = (a);i < b;i ++) 7 #define _rep(i,a,b) for(int i = (a);i > b;i --) 8 9 inline ll read() 10 { 11 ll ans = 0; 12 char ch = getchar(), last = ' '; 13 while(!isdigit(ch)) last = ch, ch = getchar(); 14 while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar(); 15 if(last == '-') ans = -ans; 16 return ans; 17 } 18 inline void write(ll x) 19 { 20 if(x < 0) x = -x, putchar('-'); 21 if(x >= 10) write(x / 10); 22 putchar(x % 10 + '0'); 23 } 24 int n; 25 int a[35]; 26 int main() 27 { 28 n = read(); 29 int cnt = 0; 30 bool rnt; 31 _for(i,1,n+1) 32 a[i] = read(); 33 _for(i,1,n+1) 34 { 35 cnt ++; 36 if(!a[i]) 37 { 38 if(cnt & 0x1) 39 rnt = false; 40 else 41 rnt = true; 42 break; 43 } 44 } 45 cnt = 0; 46 if(!rnt) 47 _rep(i,n,0) 48 { 49 cnt ++; 50 if(!a[i]) 51 { 52 if(cnt & 0x1) 53 rnt = false; 54 else 55 rnt = true; 56 break; 57 } 58 } 59 if(rnt) 60 printf("YES "); 61 else 62 printf("NO "); 63 return 0; 64 }