#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int N, P=1, a; cin >> N;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    P *= (2-a%2);
	}
	cout << pow(3, N)-P << endl;
	return 0;
}
