#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n,tmp,odd=1;
    cin>>n;
    for(int i = 0; i < n; i++){cin>>tmp;if(!(tmp%2))odd*=2;}
    cout<<pow(3,n)-odd<<endl;
    return 0;
}