program main
  implicit none
  integer(16) i, N, ans, lim, frag, frag2
  integer(16),allocatable :: A(:)
  read(*, *)N
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)
  ans = 1
  lim = 1
  frag = 0
  frag2 = 1
  do i = 1,18
    lim = lim * 10
  end do
  !lim = 10**18
  do i = 1,N
    ans = ans*A(i)
    if (ans > lim) then
      frag = 1
    endif
    if (A(i) == 0) then
      frag2 = 0
    endif
  end do
  !frag = frag * frag2
  if (frag == 1) then
    ans = -1
  end if
  if (frag2 == 0) then
    ans = 0
  end if
  write(*, *) ans
end program main
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QQcl.ec5adbed6f67fc512365ee4187b72fbe = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1277/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i128, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ec5adbed6f67fc512365ee4187b72fbe, i32 5)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 16)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i128, ptr %1, align 8, !tbaa !3
  %6 = trunc i128 %5 to i64
  %7 = call i64 @llvm.smax.i64(i64 %6, i64 0)
  %8 = shl i64 %7, 4
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEa.0, align 8, !tbaa !7
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ec5adbed6f67fc512365ee4187b72fbe, i32 7)
  %11 = load i128, ptr %1, align 8, !tbaa !3
  %12 = trunc i128 %11 to i64
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %14 = phi i64 [ %18, %.lr.ph ], [ 1, %0 ]
  %.unpack119 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %15 = add i64 %14, -1
  %16 = getelementptr i128, ptr %.unpack119, i64 %15
  %17 = call i1 @_FortranAioInputInteger(ptr %10, ptr %16, i32 16)
  %18 = add nuw i64 %14, 1
  %exitcond.not = icmp eq i64 %14, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %19 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %20 = load i128, ptr %1, align 8, !tbaa !3
  %21 = trunc i128 %20 to i64
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %.lr.ph137, label %._crit_edge138

.lr.ph137:                                        ; preds = %._crit_edge
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %xtraiter = and i64 %21, 1
  %23 = icmp eq i64 %21, 1
  br i1 %23, label %._crit_edge138.loopexit.unr-lcssa, label %.lr.ph137.new

.lr.ph137.new:                                    ; preds = %.lr.ph137
  %unroll_iter = and i64 %21, -2
  br label %24

24:                                               ; preds = %24, %.lr.ph137.new
  %25 = phi i64 [ 1, %.lr.ph137.new ], [ %39, %24 ]
  %.079135 = phi i128 [ 1, %.lr.ph137.new ], [ %.1.1, %24 ]
  %.080134 = phi i128 [ 0, %.lr.ph137.new ], [ %spec.select.1, %24 ]
  %.082133 = phi i128 [ 1, %.lr.ph137.new ], [ %34, %24 ]
  %niter = phi i64 [ 0, %.lr.ph137.new ], [ %niter.next.1, %24 ]
  %26 = add nsw i64 %25, -1
  %27 = getelementptr i128, ptr %.unpack, i64 %26
  %28 = load i128, ptr %27, align 8, !tbaa !3
  %29 = mul i128 %28, %.082133
  %30 = icmp sgt i128 %29, 1000000000000000000
  %31 = icmp eq i128 %28, 0
  %32 = getelementptr i128, ptr %.unpack, i64 %25
  %33 = load i128, ptr %32, align 8, !tbaa !3
  %34 = mul i128 %33, %29
  %35 = icmp sgt i128 %34, 1000000000000000000
  %36 = or i1 %35, %30
  %spec.select.1 = select i1 %36, i128 1, i128 %.080134
  %37 = icmp eq i128 %33, 0
  %38 = select i1 %37, i1 true, i1 %31
  %.1.1 = select i1 %38, i128 0, i128 %.079135
  %39 = add nuw i64 %25, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge138.loopexit.unr-lcssa.loopexit, label %24

._crit_edge138.loopexit.unr-lcssa.loopexit:       ; preds = %24
  %40 = add i64 %25, 1
  br label %._crit_edge138.loopexit.unr-lcssa

._crit_edge138.loopexit.unr-lcssa:                ; preds = %._crit_edge138.loopexit.unr-lcssa.loopexit, %.lr.ph137
  %.lcssa.ph = phi i128 [ undef, %.lr.ph137 ], [ %34, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %spec.select.lcssa.ph = phi i128 [ undef, %.lr.ph137 ], [ %spec.select.1, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %.1.lcssa.ph = phi i128 [ undef, %.lr.ph137 ], [ %.1.1, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %.unr = phi i64 [ 0, %.lr.ph137 ], [ %40, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %.079135.unr = phi i128 [ 1, %.lr.ph137 ], [ %.1.1, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %.080134.unr = phi i128 [ 0, %.lr.ph137 ], [ %spec.select.1, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %.082133.unr = phi i128 [ 1, %.lr.ph137 ], [ %34, %._crit_edge138.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge138.loopexit, label %._crit_edge138.loopexit.epilog-lcssa

._crit_edge138.loopexit.epilog-lcssa:             ; preds = %._crit_edge138.loopexit.unr-lcssa
  %41 = getelementptr i128, ptr %.unpack, i64 %.unr
  %42 = load i128, ptr %41, align 8, !tbaa !3
  %43 = mul i128 %42, %.082133.unr
  %44 = icmp sgt i128 %43, 1000000000000000000
  %spec.select.epil = select i1 %44, i128 1, i128 %.080134.unr
  %45 = icmp eq i128 %42, 0
  %.1.epil = select i1 %45, i128 0, i128 %.079135.unr
  br label %._crit_edge138.loopexit

._crit_edge138.loopexit:                          ; preds = %._crit_edge138.loopexit.unr-lcssa, %._crit_edge138.loopexit.epilog-lcssa
  %.lcssa = phi i128 [ %.lcssa.ph, %._crit_edge138.loopexit.unr-lcssa ], [ %43, %._crit_edge138.loopexit.epilog-lcssa ]
  %spec.select.lcssa = phi i128 [ %spec.select.lcssa.ph, %._crit_edge138.loopexit.unr-lcssa ], [ %spec.select.epil, %._crit_edge138.loopexit.epilog-lcssa ]
  %.1.lcssa = phi i128 [ %.1.lcssa.ph, %._crit_edge138.loopexit.unr-lcssa ], [ %.1.epil, %._crit_edge138.loopexit.epilog-lcssa ]
  %46 = icmp eq i128 %spec.select.lcssa, 1
  %47 = select i1 %46, i128 -1, i128 %.lcssa
  %48 = icmp eq i128 %.1.lcssa, 0
  %49 = select i1 %48, i128 0, i128 %47
  br label %._crit_edge138

._crit_edge138:                                   ; preds = %._crit_edge138.loopexit, %._crit_edge
  %.079.lcssa = phi i128 [ 1, %._crit_edge ], [ %49, %._crit_edge138.loopexit ]
  %50 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.ec5adbed6f67fc512365ee4187b72fbe, i32 32)
  %51 = call i1 @_FortranAioOutputInteger128(ptr %50, i128 %.079.lcssa)
  %52 = call i32 @_FortranAioEndIoStatement(ptr %50)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger128(ptr, i128) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #1

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
