#include<bits/stdc++.h>
using namespace std;
int n,a[10000];
long long sum1=1,sum2=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum1*=3;
		if(a[i]&1)sum2*=1;
		else sum2*=2;
	}
	printf("%lld",sum1-sum2);
}