program bbb
implicit none

integer :: n, i, m, res
integer,allocatable,dimension(:) :: h

read*, n
allocate(h(0:n))
read*, h(1:n)
h(0)=0

res=0
m=h(0)

do i=1,n
if(h(i)>=m) then
res=res+1
m=h(i)
end if
end do

write(*,'(i0)') res

end program
; 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"

@_QFEh.0 = internal unnamed_addr global ptr null
@_QFEh.7 = internal unnamed_addr global i64 1
@_QQcl.2071e54669ea36ab717d336000479a87 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4467/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.2071e54669ea36ab717d336000479a87, 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 -1)
  %8 = sext i32 %7 to i64
  %9 = add nsw i64 %8, 1
  %10 = shl nuw nsw i64 %9, 2
  %11 = call ptr @malloc(i64 %10)
  %12 = icmp eq i64 %9, 0
  %13 = zext i1 %12 to i64
  store ptr %11, ptr @_QFEh.0, align 8, !tbaa !7
  store i64 %13, ptr @_QFEh.7, align 8, !tbaa !7
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2071e54669ea36ab717d336000479a87, i32 9)
  %.unpack = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %.unpack182.unpack.unpack = load i64, ptr @_QFEh.7, align 8, !tbaa !7
  %15 = load i32, ptr %2, align 4, !tbaa !3
  %16 = sub i64 1, %.unpack182.unpack.unpack
  %17 = call i32 @llvm.smax.i32(i32 %15, i32 0)
  %18 = zext i32 %17 to i64
  %19 = getelementptr i32, ptr %.unpack, i64 %16
  store ptr %19, 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 %18, 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
  %20 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %1)
  %21 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %.unpack187 = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %.unpack194.unpack.unpack = load i64, ptr @_QFEh.7, align 8, !tbaa !7
  %22 = sub i64 0, %.unpack194.unpack.unpack
  %23 = getelementptr i32, ptr %.unpack187, i64 %22
  store i32 0, ptr %23, align 4, !tbaa !3
  %24 = load i32, ptr %2, align 4, !tbaa !3
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %26 = zext i32 %24 to i64
  %xtraiter = and i64 %26, 1
  %27 = icmp eq i32 %24, 1
  br i1 %27, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %26, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %.0225 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %spec.select223.1, %.lr.ph ]
  %.0163224 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %spec.select.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %28 = sub i64 %indvars.iv, %.unpack194.unpack.unpack
  %29 = getelementptr i32, ptr %.unpack187, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !3
  %.not = icmp sge i32 %30, %.0163224
  %spec.select = call i32 @llvm.smax.i32(i32 %30, i32 %.0163224)
  %31 = zext i1 %.not to i32
  %spec.select223 = add i32 %.0225, %31
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = sub i64 %indvars.iv.next, %.unpack194.unpack.unpack
  %33 = getelementptr i32, ptr %.unpack187, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !3
  %.not.1 = icmp sge i32 %34, %spec.select
  %spec.select.1 = call i32 @llvm.smax.i32(i32 %34, i32 %spec.select)
  %35 = zext i1 %.not.1 to i32
  %spec.select223.1 = add i32 %spec.select223, %35
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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_edge.loopexit.unr-lcssa, label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %spec.select223.lcssa.ph = phi i32 [ undef, %.lr.ph.preheader ], [ %spec.select223.1, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %.0225.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %spec.select223.1, %.lr.ph ]
  %.0163224.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %36 = sub i64 %indvars.iv.unr, %.unpack194.unpack.unpack
  %37 = getelementptr i32, ptr %.unpack187, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !3
  %.not.epil = icmp sge i32 %38, %.0163224.unr
  %39 = zext i1 %.not.epil to i32
  %spec.select223.epil = add i32 %.0225.unr, %39
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %spec.select223.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select223.epil, %.lr.ph.epil ]
  %40 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.2071e54669ea36ab717d336000479a87, i32 22)
  %41 = call i1 @_FortranAioOutputInteger32(ptr %40, i32 %.0.lcssa)
  %42 = call i32 @_FortranAioEndIoStatement(ptr %40)
  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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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}
