辣鸡题。。
省选考模拟 简直良心。。
#include <cstdio>
int n,a[10010],b[10010];
int read_int () {
char c = getchar();
int re = 0;
for(;c > '9' || c < '0';c = getchar());
for(;c >= '0' && c <= '9';c = getchar())
re = re * 10 + c - '0';
return re;
}
int hehe () {
for(int i = 2;i <= n;++i) {
if(b[i - 1] < 0)
return 0;
if(b[i - 1] == 1) {
--b[i - 1];
--b[i];
--b[i + 1];
}
}
if(b[n] != 0)
return 0;
return 1;
}
int main () {
n = read_int();
for(int i = 1;i <= n;++i)
b[i] = a[i] = read_int();
--b[1];--b[2];
int t = hehe();
for(int i = 1;i <= n;++i)
b[i] = a[i];
t += hehe();
printf("%d\n",t);
}