program abc169b
  use iso_fortran_env
  implicit none

  integer :: n, i
  integer(int64) :: x, a(100000)
  integer(int64),parameter :: mx = 10_8**18

  read *, n
  read *, a(1:n)

  if (any(a(1:n) == 0)) then
     print *, 0
     stop
  end if

  x = 1

  do i = 1,n
     if((mx+x-1) / x * a(i) > mx .and. (mx+a(i)-1) / a(i) * x > mx) then
        print *, -1
        stop
     else
        x = x * a(i)
     end if
  end do

  print *, x
end program abc169b
