#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	bool f = 0;
	int n;
	int s = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if(a%2 == 0)
			s++;
		if(a == 1)
			f = 1;
	}
	int ans;
	if(f){
		ans = pow(3,n-1)*2-pow(2,s);
	}
	else{
		ans = pow(3,n)-pow(2,s);
	}
	printf("%d",ans);
} 