program main
  implicit none
  integer(8) i,HS,CS,N
  integer(8),allocatable :: H(:)
  read(*, *) N
  allocate(H(N))
  read(*, *) (H(i), i = 1,N)
  HS = 0
  CS = 0
  if (N == 1) then
    HS = 0
  else
    do i =1,N-2
      if (H(i) >= H(i+1)) then
        CS = CS + 1
      else
        if (CS > HS) then
          HS = CS
        end if
        CS = 0
      endif
    end do
    if (H(N-1) >= H(N)) then
      CS = CS + 1
      if (CS > HS) then
        HS = CS
      end if
    else
      if (CS > HS) then
        HS = CS
      end if
    endif
  end if

  write(*, *) HS
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"

@_QFEh.0 = internal unnamed_addr global ptr null
@_QQcl.cfc21348eb1f07c3f749a866763efa9b = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3374/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 i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.cfc21348eb1f07c3f749a866763efa9b, i32 5)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = call i64 @llvm.smax.i64(i64 %5, i64 0)
  %7 = shl i64 %6, 3
  %8 = call ptr @malloc(i64 %7)
  store ptr %8, ptr @_QFEh.0, align 8, !tbaa !7
  %9 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.cfc21348eb1f07c3f749a866763efa9b, i32 7)
  %10 = load i64, ptr %1, align 8, !tbaa !3
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  %17 = call i32 @_FortranAioEndIoStatement(ptr %9)
  %18 = load i64, ptr %1, align 8, !tbaa !3
  %19 = icmp eq i64 %18, 1
  br i1 %19, label %56, label %20

20:                                               ; preds = %._crit_edge
  %21 = add i64 %18, -2
  %22 = icmp sgt i64 %21, 0
  %.unpack108 = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  br i1 %22, label %.lr.ph138, label %._crit_edge139

.lr.ph138:                                        ; preds = %20
  %xtraiter = and i64 %18, 1
  %23 = icmp eq i64 %18, 3
  br i1 %23, label %._crit_edge139.loopexit.unr-lcssa, label %.lr.ph138.new

.lr.ph138.new:                                    ; preds = %.lr.ph138
  %24 = and i64 %18, -2
  %25 = add i64 %24, -4
  br label %26

26:                                               ; preds = %26, %.lr.ph138.new
  %27 = phi i64 [ 1, %.lr.ph138.new ], [ %37, %26 ]
  %.0136 = phi i64 [ 0, %.lr.ph138.new ], [ %.2.1, %26 ]
  %.082135 = phi i64 [ 0, %.lr.ph138.new ], [ %.183.1, %26 ]
  %niter = phi i64 [ 0, %.lr.ph138.new ], [ %niter.next.1, %26 ]
  %28 = add nsw i64 %27, -1
  %29 = getelementptr i64, ptr %.unpack108, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !3
  %31 = add nuw i64 %27, 1
  %32 = getelementptr i64, ptr %.unpack108, i64 %27
  %33 = load i64, ptr %32, align 8, !tbaa !3
  %.not120 = icmp slt i64 %30, %33
  %34 = add i64 %.082135, 1
  %spec.select = call i64 @llvm.smax.i64(i64 %.082135, i64 %.0136)
  %.183 = select i1 %.not120, i64 0, i64 %34
  %.2 = select i1 %.not120, i64 %spec.select, i64 %.0136
  %35 = getelementptr i64, ptr %.unpack108, i64 %27
  %36 = load i64, ptr %35, align 8, !tbaa !3
  %37 = add nuw i64 %27, 2
  %38 = getelementptr i64, ptr %.unpack108, i64 %31
  %39 = load i64, ptr %38, align 8, !tbaa !3
  %.not120.1 = icmp slt i64 %36, %39
  %40 = add i64 %.183, 1
  %spec.select.1 = call i64 @llvm.smax.i64(i64 %.183, i64 %.2)
  %.183.1 = select i1 %.not120.1, i64 0, i64 %40
  %.2.1 = select i1 %.not120.1, i64 %spec.select.1, i64 %.2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %25
  br i1 %niter.ncmp.1, label %._crit_edge139.loopexit.unr-lcssa, label %26

._crit_edge139.loopexit.unr-lcssa:                ; preds = %26, %.lr.ph138
  %.183.lcssa.ph = phi i64 [ undef, %.lr.ph138 ], [ %.183.1, %26 ]
  %.2.lcssa.ph = phi i64 [ undef, %.lr.ph138 ], [ %.2.1, %26 ]
  %.unr = phi i64 [ 1, %.lr.ph138 ], [ %37, %26 ]
  %.0136.unr = phi i64 [ 0, %.lr.ph138 ], [ %.2.1, %26 ]
  %.082135.unr = phi i64 [ 0, %.lr.ph138 ], [ %.183.1, %26 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge139, label %._crit_edge139.loopexit.epilog-lcssa

._crit_edge139.loopexit.epilog-lcssa:             ; preds = %._crit_edge139.loopexit.unr-lcssa
  %41 = add i64 %.unr, -1
  %42 = getelementptr i64, ptr %.unpack108, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !3
  %44 = getelementptr i64, ptr %.unpack108, i64 %.unr
  %45 = load i64, ptr %44, align 8, !tbaa !3
  %.not120.epil = icmp slt i64 %43, %45
  %46 = add i64 %.082135.unr, 1
  %spec.select.epil = call i64 @llvm.smax.i64(i64 %.082135.unr, i64 %.0136.unr)
  %.183.epil = select i1 %.not120.epil, i64 0, i64 %46
  %.2.epil = select i1 %.not120.epil, i64 %spec.select.epil, i64 %.0136.unr
  br label %._crit_edge139

._crit_edge139:                                   ; preds = %._crit_edge139.loopexit.epilog-lcssa, %._crit_edge139.loopexit.unr-lcssa, %20
  %.082.lcssa = phi i64 [ 0, %20 ], [ %.183.lcssa.ph, %._crit_edge139.loopexit.unr-lcssa ], [ %.183.epil, %._crit_edge139.loopexit.epilog-lcssa ]
  %.0.lcssa = phi i64 [ 0, %20 ], [ %.2.lcssa.ph, %._crit_edge139.loopexit.unr-lcssa ], [ %.2.epil, %._crit_edge139.loopexit.epilog-lcssa ]
  %47 = add i64 %18, -2
  %48 = getelementptr i64, ptr %.unpack108, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !3
  %50 = add i64 %18, -1
  %51 = getelementptr i64, ptr %.unpack108, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !3
  %.not = icmp slt i64 %49, %52
  br i1 %.not, label %55, label %53

53:                                               ; preds = %._crit_edge139
  %54 = add i64 %.082.lcssa, 1
  %spec.select133 = call i64 @llvm.smax.i64(i64 %54, i64 %.0.lcssa)
  br label %56

55:                                               ; preds = %._crit_edge139
  %spec.select134 = call i64 @llvm.smax.i64(i64 %.082.lcssa, i64 %.0.lcssa)
  br label %56

56:                                               ; preds = %55, %53, %._crit_edge
  %.3 = phi i64 [ 0, %._crit_edge ], [ %spec.select133, %53 ], [ %spec.select134, %55 ]
  %57 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.cfc21348eb1f07c3f749a866763efa9b, i32 35)
  %58 = call i1 @_FortranAioOutputInteger64(ptr %57, i64 %.3)
  %59 = call i32 @_FortranAioEndIoStatement(ptr %57)
  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 @_FortranAioOutputInteger64(ptr, i64) 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}
