program mp2
  implicit none
  integer(16) :: N, i
  integer(16),allocatable :: a(:)
  integer(16) :: r

  read(*,*) N
  allocate(a(N))
  read(*,*) a

  do i = 1, N
     if (a(i) == 0) then
        write(*,*) 0
        stop
     end if
  end do

  r = 1_16
  do i = 1, N
     r = r * a(i)
     if (r > 10_16**18_16) then
        write(*,*) -1
        stop
     end if
  end do
  write(*,*) r
  deallocate(a)
  stop
end program mp2

; 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
@_QFEa.8 = internal unnamed_addr global i64 0
@_QQcl.d669d4266837a0ae46ea946655695f9b = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1275/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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #2 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i128, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.d669d4266837a0ae46ea946655695f9b, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 16)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i128, ptr %2, align 8, !tbaa !3
  %7 = trunc i128 %6 to i64
  %8 = call i64 @llvm.smax.i64(i64 %7, i64 0)
  %9 = shl i64 %8, 4
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEa.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.d669d4266837a0ae46ea946655695f9b, i32 9)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack196.unpack.unpack198 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 16, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 11, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack196.unpack.unpack198, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 16, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %12 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %13 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %14 = load i128, ptr %2, align 8, !tbaa !3
  %15 = icmp sgt i128 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack225 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  br label %16

.preheader:                                       ; preds = %26
  br i1 %15, label %.lr.ph243, label %._crit_edge

.lr.ph243:                                        ; preds = %.preheader
  %.unpack213 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  br label %30

16:                                               ; preds = %.lr.ph, %26
  %.0177239 = phi i64 [ 1, %.lr.ph ], [ %28, %26 ]
  %.0178238 = phi i128 [ %14, %.lr.ph ], [ %27, %26 ]
  %17 = add i64 %.0177239, -1
  %18 = getelementptr i128, ptr %.unpack225, i64 %17
  %19 = load i128, ptr %18, align 8, !tbaa !3
  %20 = icmp eq i128 %19, 0
  br i1 %20, label %21, label %26

21:                                               ; preds = %16
  %22 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.d669d4266837a0ae46ea946655695f9b, i32 13)
  %23 = call i1 @_FortranAioOutputInteger32(ptr %22, i32 0)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %22)
  %25 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

26:                                               ; preds = %16
  %27 = add nsw i128 %.0178238, -1
  %28 = add i64 %.0177239, 1
  %29 = icmp sgt i128 %.0178238, 1
  br i1 %29, label %16, label %.preheader

30:                                               ; preds = %.lr.ph243, %41
  %.0242 = phi i128 [ 1, %.lr.ph243 ], [ %34, %41 ]
  %.1241 = phi i64 [ 1, %.lr.ph243 ], [ %43, %41 ]
  %.0179240 = phi i128 [ %14, %.lr.ph243 ], [ %42, %41 ]
  %31 = add i64 %.1241, -1
  %32 = getelementptr i128, ptr %.unpack213, i64 %31
  %33 = load i128, ptr %32, align 8, !tbaa !3
  %34 = mul i128 %33, %.0242
  %35 = icmp sgt i128 %34, 1000000000000000000
  br i1 %35, label %36, label %41

36:                                               ; preds = %30
  %37 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.d669d4266837a0ae46ea946655695f9b, i32 22)
  %38 = call i1 @_FortranAioOutputInteger32(ptr %37, i32 -1)
  %39 = call i32 @_FortranAioEndIoStatement(ptr %37)
  %40 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

41:                                               ; preds = %30
  %42 = add nsw i128 %.0179240, -1
  %43 = add i64 %.1241, 1
  %44 = icmp sgt i128 %.0179240, 1
  br i1 %44, label %30, label %._crit_edge

._crit_edge:                                      ; preds = %41, %0, %.preheader
  %.0.lcssa = phi i128 [ 1, %.preheader ], [ 1, %0 ], [ %34, %41 ]
  %45 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.d669d4266837a0ae46ea946655695f9b, i32 26)
  %46 = call i1 @_FortranAioOutputInteger128(ptr %45, i128 %.0.lcssa)
  %47 = call i32 @_FortranAioEndIoStatement(ptr %45)
  %.unpack201 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  call void @free(ptr %.unpack201)
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 0, ptr @_QFEa.8, align 8, !tbaa !7
  %48 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) 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) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { noreturn }
attributes #3 = { 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}
