func pow(x: Int, _ y: Int) -> Int {
  return (0..<y).reduce(1){i,_ in i*x}
}
let N = Int(readLine()!)!
let n = readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count
print(pow(3,N)-pow(2,n))