defmodule Main do
  def main do
    IO.gets("")
    list = IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    list |> multiplication() |> IO.puts()
  end

  @doc """
  Multiplication

  ## Examples

      iex> Multiplication2.multiplication([1000000000, 1000000000])
      1000000000000000000
      iex> Multiplication2.multiplication([101, 9901, 999999000001])
      -1
      iex> Multiplication2.multiplication([4, 1, 5, 0])
      0

  """

  def multiplication(list) do
    if 0 in list do
      0
    else
      list
      |> Enum.reduce_while(1, fn n, acc ->
        result = value(acc * n)
        if result > 0, do: {:cont, result}, else: {:halt, result}
      end)
    end
  end

  defp value(n) when n > 1_000_000_000_000_000_000, do: -1
  defp value(n), do: n
end