open Printf
open Scanf

let () =
  let n = scanf "%d " (fun x -> x) in
  let rec read i =
    if i = 0 then []
    else let v = scanf "%d " (fun x -> x) in
         v :: read (i - 1) in
  let ls = read n in
  let rec expt3 n =
    if n = 0 then 1 else 3 * (expt3 (n - 1)) in
  expt3 n - (List.fold_left (fun a x -> if x mod 2 = 0 then a * 2 else a) 1 ls) |> printf "%d\n"
