#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;

	int i;

	int odd=1;
	int num=1;
	int A;
	for (i=0;i<N;i++){
		cin>>A;
		if (A%2==0){
			odd*=2;
		}
		num*=3;
	}
	cout<<num-odd<<endl;
	return 0;
}