PROGRAM ATCODER

implicit none
integer :: n,i,r1,r2,b1,b2,c1,c2
integer,allocatable :: a(:),a_l(:),a_r(:),ans(:)

read*, n
allocate(a(n),a_l(n),a_r(n),ans(n))
read*, a(1:n)

a_l(1) = a(1)
a_r(1) = a(n)

do i = 2, n
  b1 = a(i)
  c1 = a_l(i-1)
  b2 = a(n+1-i)
  c2 = a_r(i-1)
  do
    r1 = mod(c1,b1)
    if ( r1 == 0 ) exit
    c1 = b1
    b1 = r1
  end do
  do
    r2 = mod(c2,b2)
    if ( r2 == 0 ) exit
    c2 = b2
    b2 = r2
  end do
  a_l(i) = b1
  a_r(i) = b2
end do

ans(1) = a_r(n-1)
ans(n) = a_l(n-1)

do i = 2, n-1
  c1 = a_l(i-1)
  b1 = a_r(n-i)
  do
    r1 = mod(c1,b1)
    if ( r1 == 0 ) exit
    c1 = b1
    b1 = r1
  end do
  ans(i) = b1
end do

print'(i0)', maxval(ans)

END PROGRAM ATCODER
; 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_l.0 = internal unnamed_addr global ptr null
@_QFEa_r.0 = internal unnamed_addr global ptr null
@_QFEans.0 = internal unnamed_addr global ptr null
@_QFEans.8 = internal unnamed_addr global i64 0
@_QQcl.aa996286b1be256c2cd913f5712fd299 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4385/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 i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.aa996286b1be256c2cd913f5712fd299, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  %9 = shl nuw nsw i64 %8, 2
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  %11 = call ptr @malloc(i64 %9)
  store ptr %11, ptr @_QFEa_l.0, align 8, !tbaa !7
  %12 = call ptr @malloc(i64 %9)
  store ptr %12, ptr @_QFEa_r.0, align 8, !tbaa !7
  %13 = call ptr @malloc(i64 %9)
  store ptr %13, ptr @_QFEans.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEans.8, align 8, !tbaa !7
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.aa996286b1be256c2cd913f5712fd299, i32 9)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %15 = load i32, ptr %2, align 4, !tbaa !3
  %16 = call i32 @llvm.smax.i32(i32 %15, i32 0)
  %17 = zext i32 %16 to i64
  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 4, 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 9, 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 %17, 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 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %18 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %1)
  %19 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %.unpack808 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %20 = load i32, ptr %.unpack808, align 4, !tbaa !3
  %.unpack820 = load ptr, ptr @_QFEa_l.0, align 8, !tbaa !7
  store i32 %20, ptr %.unpack820, align 4, !tbaa !3
  %21 = load i32, ptr %2, align 4, !tbaa !3
  %22 = sext i32 %21 to i64
  %23 = add nsw i64 %22, -1
  %24 = getelementptr i32, ptr %.unpack808, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !3
  %.unpack844 = load ptr, ptr @_QFEa_r.0, align 8, !tbaa !7
  store i32 %25, ptr %.unpack844, align 4, !tbaa !3
  %26 = load i32, ptr %2, align 4, !tbaa !3
  %.07571012 = add i32 %26, -1
  %27 = icmp sgt i32 %.07571012, 0
  br i1 %27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %52
  %.07501013 = phi i32 [ %57, %52 ], [ 2, %0 ]
  %28 = sext i32 %.07501013 to i64
  %29 = add nsw i64 %28, -1
  %30 = getelementptr i32, ptr %.unpack808, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !3
  %32 = add i32 %.07501013, -1
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %33, -1
  %35 = getelementptr i32, ptr %.unpack820, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !3
  %37 = load i32, ptr %2, align 4, !tbaa !3
  %38 = sub i32 1, %.07501013
  %39 = add i32 %38, %37
  %40 = sext i32 %39 to i64
  %41 = add nsw i64 %40, -1
  %42 = getelementptr i32, ptr %.unpack808, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !3
  %44 = add nsw i64 %33, -1
  %45 = getelementptr i32, ptr %.unpack844, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  br label %47

47:                                               ; preds = %47, %.lr.ph
  %.0755 = phi i32 [ %31, %.lr.ph ], [ %48, %47 ]
  %.0752 = phi i32 [ %36, %.lr.ph ], [ %.0755, %47 ]
  %48 = srem i32 %.0752, %.0755
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %.preheader, label %47

.preheader:                                       ; preds = %47, %.preheader
  %.0754 = phi i32 [ %50, %.preheader ], [ %43, %47 ]
  %.0751 = phi i32 [ %.0754, %.preheader ], [ %46, %47 ]
  %50 = srem i32 %.0751, %.0754
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %.preheader

52:                                               ; preds = %.preheader
  %53 = add nsw i64 %28, -1
  %54 = getelementptr i32, ptr %.unpack820, i64 %53
  store i32 %.0755, ptr %54, align 4, !tbaa !3
  %55 = add nsw i64 %28, -1
  %56 = getelementptr i32, ptr %.unpack844, i64 %55
  store i32 %.0754, ptr %56, align 4, !tbaa !3
  %57 = add nuw i32 %.07501013, 1
  %exitcond.not = icmp eq i32 %.07501013, %26
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %52
  %.pre = load i32, ptr %2, align 4, !tbaa !3
  %.pre1021 = add i32 %.pre, -1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.pre-phi = phi i32 [ %.pre1021, %._crit_edge.loopexit ], [ %.07571012, %0 ]
  %58 = sext i32 %.pre-phi to i64
  %59 = add nsw i64 %58, -1
  %60 = getelementptr i32, ptr %.unpack844, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !3
  %.unpack868 = load ptr, ptr @_QFEans.0, align 8, !tbaa !7
  store i32 %61, ptr %.unpack868, align 4, !tbaa !3
  %62 = load i32, ptr %2, align 4, !tbaa !3
  %63 = add i32 %62, -1
  %64 = sext i32 %63 to i64
  %65 = add nsw i64 %64, -1
  %66 = getelementptr i32, ptr %.unpack820, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !3
  %68 = sext i32 %62 to i64
  %69 = add nsw i64 %68, -1
  %70 = getelementptr i32, ptr %.unpack868, i64 %69
  store i32 %67, ptr %70, align 4, !tbaa !3
  %71 = load i32, ptr %2, align 4, !tbaa !3
  %72 = add i32 %71, -2
  %73 = icmp sgt i32 %72, 0
  br i1 %73, label %.lr.ph1018, label %._crit_edge1019

.lr.ph1018:                                       ; preds = %._crit_edge, %88
  %.11015 = phi i32 [ %92, %88 ], [ 2, %._crit_edge ]
  %74 = add i32 %.11015, -1
  %75 = sext i32 %74 to i64
  %76 = add nsw i64 %75, -1
  %77 = getelementptr i32, ptr %.unpack820, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !3
  %79 = load i32, ptr %2, align 4, !tbaa !3
  %80 = sub i32 %79, %.11015
  %81 = sext i32 %80 to i64
  %82 = add nsw i64 %81, -1
  %83 = getelementptr i32, ptr %.unpack844, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !3
  br label %85

85:                                               ; preds = %85, %.lr.ph1018
  %.1756 = phi i32 [ %84, %.lr.ph1018 ], [ %86, %85 ]
  %.1753 = phi i32 [ %78, %.lr.ph1018 ], [ %.1756, %85 ]
  %86 = srem i32 %.1753, %.1756
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %85

88:                                               ; preds = %85
  %89 = sext i32 %.11015 to i64
  %90 = add nsw i64 %89, -1
  %91 = getelementptr i32, ptr %.unpack868, i64 %90
  store i32 %.1756, ptr %91, align 4, !tbaa !3
  %92 = add nuw i32 %.11015, 1
  %exitcond1020.not = icmp eq i32 %92, %71
  br i1 %exitcond1020.not, label %._crit_edge1019, label %.lr.ph1018

._crit_edge1019:                                  ; preds = %88, %._crit_edge
  %93 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.aa996286b1be256c2cd913f5712fd299, i32 50)
  %.unpack904 = load ptr, ptr @_QFEans.0, align 8, !tbaa !7
  %.unpack911.unpack.unpack913 = load i64, ptr @_QFEans.8, align 8, !tbaa !7
  %94 = icmp sgt i64 %.unpack911.unpack.unpack913, 0
  br i1 %94, label %.lr.ph.i.preheader, label %_FortranAMaxvalInteger4x1_contract_simplified.exit

.lr.ph.i.preheader:                               ; preds = %._crit_edge1019
  %min.iters.check = icmp ult i64 %.unpack911.unpack.unpack913, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader1024, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %.unpack911.unpack.unpack913, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %98, %vector.body ]
  %vec.phi1022 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %99, %vector.body ]
  %95 = shl i64 %index, 2
  %96 = getelementptr i8, ptr %.unpack904, i64 %95
  %wide.load = load <4 x i32>, ptr %96, align 4, !tbaa !3
  %97 = getelementptr i32, ptr %96, i64 4
  %wide.load1023 = load <4 x i32>, ptr %97, align 4, !tbaa !3
  %98 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %99 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load1023, <4 x i32> %vec.phi1022)
  %index.next = add nuw i64 %index, 8
  %100 = icmp eq i64 %index.next, %n.vec
  br i1 %100, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %98, <4 x i32> %99)
  %101 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %cmp.n = icmp eq i64 %.unpack911.unpack.unpack913, %n.vec
  br i1 %cmp.n, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader1024

.lr.ph.i.preheader1024:                           ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i32 [ -2147483648, %.lr.ph.i.preheader ], [ %101, %middle.block ]
  %.ph1025 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader1024, %.lr.ph.i
  %102 = phi i32 [ %107, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader1024 ]
  %103 = phi i64 [ %108, %.lr.ph.i ], [ %.ph1025, %.lr.ph.i.preheader1024 ]
  %104 = shl i64 %103, 2
  %105 = getelementptr i8, ptr %.unpack904, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !3
  %107 = call i32 @llvm.smax.i32(i32 %106, i32 %102)
  %108 = add nuw nsw i64 %103, 1
  %exitcond.not.i = icmp eq i64 %108, %.unpack911.unpack.unpack913
  br i1 %exitcond.not.i, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranAMaxvalInteger4x1_contract_simplified.exit: ; preds = %.lr.ph.i, %middle.block, %._crit_edge1019
  %.lcssa.i = phi i32 [ -2147483648, %._crit_edge1019 ], [ %101, %middle.block ], [ %107, %.lr.ph.i ]
  %109 = call i1 @_FortranAioOutputInteger32(ptr %93, i32 %.lcssa.i)
  %110 = call i32 @_FortranAioEndIoStatement(ptr %93)
  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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind 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}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
