#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100010],b[100010];
int ans,n;
bool judge(int x)
{
if(a[x-1]+a[x]+a[x+1]==b[x])
return 1;
else return 0;
}
void dfs(int k)
{
if(k==n)
{
if(judge(n))
ans++;
return ;
}
a[k]=1;
if(judge(k))
dfs(k+1);
a[k]=0;
if(judge(k))
dfs(k+1);
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
scanf("%d",&b[i]);
}
dfs(1);
cout<<ans;
return 0;
}