let () = Scanf.scanf "%d\n" @@ fun n ->
  let array = Array.init n @@ fun i -> if i<n-1 then Scanf.scanf "%d " @@ fun a -> a else Scanf.scanf "%d" @@ fun a -> a in 
  Printf.printf "%d\n" @@
  Array.fold_left (fun acc a ->
    if a = 0 || acc = 0
    then 0
    else if acc = -1
    then -1
    else if acc <= 1000000000000000000 / a
    then acc * a
    else -1) 1 array