program main
  implicit none
  integer(8) :: n, i, res, r
  integer(8), allocatable :: a(:), left(:), right(:)
  read (*, *) n
  allocate (a(n), left(n), right(n))
  read (*, *) a(:)
  left(1) = a(1)
  do i = 2, n
    left(i) = gcd(left(i - 1), a(i))
  end do
  right(n) = a(n)
  do i = n - 1, 1, -1
    right(i) = gcd(right(i + 1), a(i))
  end do
  res = 1
  do i = 1, n
    if (i == 1) then
      r = right(2)
    else if (i == n) then
      r = left(n - 1)
    else
      r = gcd(left(i - 1), right(i + 1))
    end if
    res = max(res, r)
  end do
  write (*, "(i0)") res
  contains
  pure function gcd(x, y) result(a)
    integer(8), intent(in) :: x, y
    integer(8) :: a, b, r
    a = max(x, y)
    b = min(x, y)
    do while (b > 0)
      r = mod(a, b)
      a = b
      b = r
    end do
  end function gcd
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
@_QFEa.8 = internal unnamed_addr global i64 0
@_QFEleft.0 = internal unnamed_addr global ptr null
@_QFEright.0 = internal unnamed_addr global ptr null
@_QQcl.0f3b2249890ad518adc959ef7fca27e0 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4388/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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 { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.0f3b2249890ad518adc959ef7fca27e0, i32 5)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i64, ptr %2, align 8, !tbaa !3
  %7 = call i64 @llvm.smax.i64(i64 %6, i64 0)
  %8 = shl i64 %7, 3
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %7, ptr @_QFEa.8, align 8, !tbaa !7
  %10 = call ptr @malloc(i64 %8)
  store ptr %10, ptr @_QFEleft.0, align 8, !tbaa !7
  %11 = call ptr @malloc(i64 %8)
  store ptr %11, ptr @_QFEright.0, align 8, !tbaa !7
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.0f3b2249890ad518adc959ef7fca27e0, i32 7)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack589.unpack.unpack591 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %13 = call i64 @llvm.smax.i64(i64 %.unpack589.unpack.unpack591, i64 0)
  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 8, 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 10, 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 %13, 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 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %14 = call i1 @_FortranAioInputDescriptor(ptr %12, ptr nonnull %1)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %.unpack594 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %16 = load i64, ptr %.unpack594, align 8, !tbaa !3
  %.unpack606 = load ptr, ptr @_QFEleft.0, align 8, !tbaa !7
  store i64 %16, ptr %.unpack606, align 8, !tbaa !3
  %17 = load i64, ptr %2, align 8, !tbaa !3
  %18 = add i64 %17, -1
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %_QFPgcd.exit
  %20 = phi i64 [ %34, %_QFPgcd.exit ], [ 2, %0 ]
  %21 = add i64 %20, -2
  %22 = getelementptr i64, ptr %.unpack606, i64 %21
  %23 = add i64 %20, -1
  %24 = getelementptr i64, ptr %.unpack594, i64 %23
  %25 = load i64, ptr %22, align 8, !tbaa !3
  %26 = load i64, ptr %24, align 8, !tbaa !3
  %27 = call i64 @llvm.smax.i64(i64 %25, i64 %26)
  %28 = call i64 @llvm.smin.i64(i64 %25, i64 %26)
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph.i, label %_QFPgcd.exit

.lr.ph.i:                                         ; preds = %.lr.ph, %.lr.ph.i
  %.08.i = phi i64 [ %.067.i, %.lr.ph.i ], [ %27, %.lr.ph ]
  %.067.i = phi i64 [ %30, %.lr.ph.i ], [ %28, %.lr.ph ]
  %30 = srem i64 %.08.i, %.067.i
  %31 = icmp sgt i64 %30, 0
  br i1 %31, label %.lr.ph.i, label %_QFPgcd.exit

_QFPgcd.exit:                                     ; preds = %.lr.ph.i, %.lr.ph
  %.0.lcssa.i = phi i64 [ %27, %.lr.ph ], [ %.067.i, %.lr.ph.i ]
  %32 = add i64 %20, -1
  %33 = getelementptr i64, ptr %.unpack606, i64 %32
  store i64 %.0.lcssa.i, ptr %33, align 8, !tbaa !3
  %34 = add nuw i64 %20, 1
  %exitcond.not = icmp eq i64 %20, %17
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %_QFPgcd.exit
  %.pre = load i64, ptr %2, align 8, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %35 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %17, %0 ]
  %36 = add i64 %35, -1
  %37 = getelementptr i64, ptr %.unpack594, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !3
  %.unpack630 = load ptr, ptr @_QFEright.0, align 8, !tbaa !7
  %39 = add i64 %35, -1
  %40 = getelementptr i64, ptr %.unpack630, i64 %39
  store i64 %38, ptr %40, align 8, !tbaa !3
  %41 = load i64, ptr %2, align 8, !tbaa !3
  %42 = add i64 %41, -1
  %43 = icmp sgt i64 %42, 0
  br i1 %43, label %.lr.ph776, label %._crit_edge777

.lr.ph776:                                        ; preds = %._crit_edge, %_QFPgcd.exit768
  %44 = phi i64 [ %59, %_QFPgcd.exit768 ], [ %42, %._crit_edge ]
  %.in774 = phi i64 [ %45, %_QFPgcd.exit768 ], [ %41, %._crit_edge ]
  %45 = add i64 %.in774, -1
  %46 = add i64 %.in774, -1
  %47 = getelementptr i64, ptr %.unpack630, i64 %46
  %48 = add i64 %.in774, -2
  %49 = getelementptr i64, ptr %.unpack594, i64 %48
  %50 = load i64, ptr %47, align 8, !tbaa !3
  %51 = load i64, ptr %49, align 8, !tbaa !3
  %52 = call i64 @llvm.smax.i64(i64 %50, i64 %51)
  %53 = call i64 @llvm.smin.i64(i64 %50, i64 %51)
  %54 = icmp sgt i64 %53, 0
  br i1 %54, label %.lr.ph.i766, label %_QFPgcd.exit768

.lr.ph.i766:                                      ; preds = %.lr.ph776, %.lr.ph.i766
  %.08.i764 = phi i64 [ %.067.i765, %.lr.ph.i766 ], [ %52, %.lr.ph776 ]
  %.067.i765 = phi i64 [ %55, %.lr.ph.i766 ], [ %53, %.lr.ph776 ]
  %55 = srem i64 %.08.i764, %.067.i765
  %56 = icmp sgt i64 %55, 0
  br i1 %56, label %.lr.ph.i766, label %_QFPgcd.exit768

_QFPgcd.exit768:                                  ; preds = %.lr.ph.i766, %.lr.ph776
  %.0.lcssa.i767 = phi i64 [ %52, %.lr.ph776 ], [ %.067.i765, %.lr.ph.i766 ]
  %57 = add i64 %.in774, -2
  %58 = getelementptr i64, ptr %.unpack630, i64 %57
  store i64 %.0.lcssa.i767, ptr %58, align 8, !tbaa !3
  %59 = add i64 %44, -1
  %60 = icmp sgt i64 %59, 0
  br i1 %60, label %.lr.ph776, label %._crit_edge777.loopexit

._crit_edge777.loopexit:                          ; preds = %_QFPgcd.exit768
  %.pre783 = load i64, ptr %2, align 8, !tbaa !3
  br label %._crit_edge777

._crit_edge777:                                   ; preds = %._crit_edge777.loopexit, %._crit_edge
  %61 = phi i64 [ %.pre783, %._crit_edge777.loopexit ], [ %41, %._crit_edge ]
  %62 = icmp sgt i64 %61, 0
  br i1 %62, label %.lr.ph780, label %._crit_edge781

.lr.ph780:                                        ; preds = %._crit_edge777
  %63 = add i64 %61, -2
  %64 = getelementptr i64, ptr %.unpack606, i64 %63
  %65 = getelementptr i64, ptr %.unpack630, i64 1
  br label %66

66:                                               ; preds = %.lr.ph780, %_QFPgcd.exit773
  %67 = phi i64 [ 1, %.lr.ph780 ], [ %84, %_QFPgcd.exit773 ]
  %.0778 = phi i64 [ 1, %.lr.ph780 ], [ %83, %_QFPgcd.exit773 ]
  %68 = icmp eq i64 %67, 1
  br i1 %68, label %_QFPgcd.exit773.sink.split, label %69

69:                                               ; preds = %66
  %70 = icmp eq i64 %67, %61
  br i1 %70, label %_QFPgcd.exit773.sink.split, label %71

71:                                               ; preds = %69
  %72 = add i64 %67, -2
  %73 = getelementptr i64, ptr %.unpack606, i64 %72
  %74 = getelementptr i64, ptr %.unpack630, i64 %67
  %75 = load i64, ptr %73, align 8, !tbaa !3
  %76 = load i64, ptr %74, align 8, !tbaa !3
  %77 = call i64 @llvm.smax.i64(i64 %75, i64 %76)
  %78 = call i64 @llvm.smin.i64(i64 %75, i64 %76)
  %79 = icmp sgt i64 %78, 0
  br i1 %79, label %.lr.ph.i771, label %_QFPgcd.exit773

.lr.ph.i771:                                      ; preds = %71, %.lr.ph.i771
  %.08.i769 = phi i64 [ %.067.i770, %.lr.ph.i771 ], [ %77, %71 ]
  %.067.i770 = phi i64 [ %80, %.lr.ph.i771 ], [ %78, %71 ]
  %80 = srem i64 %.08.i769, %.067.i770
  %81 = icmp sgt i64 %80, 0
  br i1 %81, label %.lr.ph.i771, label %_QFPgcd.exit773

_QFPgcd.exit773.sink.split:                       ; preds = %69, %66
  %.sink = phi ptr [ %65, %66 ], [ %64, %69 ]
  %82 = load i64, ptr %.sink, align 8, !tbaa !3
  br label %_QFPgcd.exit773

_QFPgcd.exit773:                                  ; preds = %.lr.ph.i771, %_QFPgcd.exit773.sink.split, %71
  %.0550 = phi i64 [ %77, %71 ], [ %82, %_QFPgcd.exit773.sink.split ], [ %.067.i770, %.lr.ph.i771 ]
  %83 = call i64 @llvm.smax.i64(i64 %.0778, i64 %.0550)
  %84 = add nuw i64 %67, 1
  %exitcond782.not = icmp eq i64 %67, %61
  br i1 %exitcond782.not, label %._crit_edge781, label %66

._crit_edge781:                                   ; preds = %_QFPgcd.exit773, %._crit_edge777
  %.0.lcssa = phi i64 [ 1, %._crit_edge777 ], [ %83, %_QFPgcd.exit773 ]
  %85 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.0f3b2249890ad518adc959ef7fca27e0, i32 27)
  %86 = call i1 @_FortranAioOutputInteger64(ptr %85, i64 %.0.lcssa)
  %87 = call i32 @_FortranAioEndIoStatement(ptr %85)
  ret void
}

; Function Attrs: nofree nosync nounwind memory(argmem: read)
define i64 @_QFPgcd(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr #1 {
  %3 = load i64, ptr %0, align 8, !tbaa !3
  %4 = load i64, ptr %1, align 8, !tbaa !3
  %5 = tail call i64 @llvm.smax.i64(i64 %3, i64 %4)
  %6 = tail call i64 @llvm.smin.i64(i64 %3, i64 %4)
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.08 = phi i64 [ %.067, %.lr.ph ], [ %5, %2 ]
  %.067 = phi i64 [ %8, %.lr.ph ], [ %6, %2 ]
  %8 = srem i64 %.08, %.067
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.0.lcssa = phi i64 [ %5, %2 ], [ %.067, %.lr.ph ]
  ret i64 %.0.lcssa
}

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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

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