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

int main() {
    long long i, input, cnt, sub=1;
    cin >> i;
    cnt = i;
    for(;i!=0;i--){
        cin >> input;
        if(input%2 == 0) sub *= 2;
    }
    cout << pow(3, cnt) - sub << endl;
}