#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int a[10001],b[10001];
int n,ans;
//递推
//a[i]=b[i-1]-a[i-1]-a[i-2];
int check(){
for(register int i=2;i<=n;i++){
a[i]=b[i-1]-a[i-1]-a[i-2];
if(a[i]<0){
return 0;
}
}
ans++;
return 0;
}
int c[10001];
int check1(){
for(register int i=2;i<=n;i++){
c[i]=b[i-1]-c[i-1]-c[i-2];
if(c[i]<0){
return 0;
}
}
ans++;
return 0;
}
int main()
{
cin>>n;//b用作输入雷数量(右) a用作放雷(左)
for(int i=1;i<=n;i++) cin>>b[i]; if(n==1) {
cout<<1;return 0;
}
a[1]=1;
check();
a[1]=0;
check1();
cout<<ans;
return 0;
}