let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun (evens, odds) a ->
    if a mod 2 = 0 then (3 * evens + odds, 2 * odds)
    else (3 * evens + 2 * odds, odds)) (0, 1) as_
  |> fst
  |> Printf.printf "%d\n"