#include <iostream>

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  long long a = 1, b = 1;
  int tmp = 0;
  for (int i=0; i<n; i++) {
    cin >> tmp;
    a *= 3;
    if (tmp%2 == 0) {
      b *= 2;
    }
  }
  cout << a - b << endl;
  return 0;
}
