#include <bits/stdc++.h>
using namespace std;

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