#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
	ll N; cin>>N;
	ll ans=1;
	rep(i,N) ans*=3;
	ll tmp=1;
	rep(i,N){
		ll x; cin>>x;
		if(x%2==0) tmp*=2;
	}
	cout<<ans-tmp;
}