let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let t, o = Array.fold_left (fun (t, o) a -> t * 3, o * if a mod 2 = 0 then 2 else 1) (1, 1) a_s
let _ = Printf.printf "%d\n" @@ t - o