integer N
integer,allocatable,dimension(:)::p
integer ans
read*,N
allocate(p(N))
read*,P

ans=0
do i=2,N-1
  if((p(i)-p(i-1))*(p(i+1)-p(i))>0)ans=ans+1
end do

print"(i0)",ans
end
; 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"

@_QFEp.0 = internal unnamed_addr global ptr null
@_QFEp.8 = internal unnamed_addr global i64 0
@_QQcl.366a6debfe6d6ab8987e975c64b75146 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3857/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.366a6debfe6d6ab8987e975c64b75146, i32 4)
  %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 @_QFEp.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEp.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.366a6debfe6d6ab8987e975c64b75146, i32 6)
  %.unpack = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %.unpack87.unpack.unpack89 = load i64, ptr @_QFEp.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 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 %.unpack87.unpack.unpack89, 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
  %12 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %13 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %14 = load i32, ptr %2, align 4, !tbaa !3
  %15 = add i32 %14, -1
  %16 = icmp sgt i32 %15, 1
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %17 = zext i32 %15 to i64
  %.unpack92 = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %18 = add nsw i64 %17, -1
  %min.iters.check = icmp ult i32 %15, 9
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %19 = add nsw i64 %17, -2
  %20 = trunc i64 %19 to i32
  %21 = icmp ugt i32 %20, 2147483644
  %22 = icmp ugt i64 %19, 4294967295
  %23 = or i1 %21, %22
  br i1 %23, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %n.vec = and i64 %18, -8
  %ind.end = or i64 %n.vec, 2
  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> [ zeroinitializer, %vector.ph ], [ %44, %vector.body ]
  %vec.phi106 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %45, %vector.body ]
  %24 = or i64 %index, 1
  %25 = getelementptr i32, ptr %.unpack92, i64 %24
  %wide.load = load <4 x i32>, ptr %25, align 4, !tbaa !3
  %26 = getelementptr i32, ptr %25, i64 4
  %wide.load107 = load <4 x i32>, ptr %26, align 4, !tbaa !3
  %27 = getelementptr i32, ptr %.unpack92, i64 %index
  %wide.load108 = load <4 x i32>, ptr %27, align 4, !tbaa !3
  %28 = getelementptr i32, ptr %27, i64 4
  %wide.load109 = load <4 x i32>, ptr %28, align 4, !tbaa !3
  %29 = sub <4 x i32> %wide.load, %wide.load108
  %30 = sub <4 x i32> %wide.load107, %wide.load109
  %31 = shl i64 %index, 32
  %32 = ashr exact i64 %31, 32
  %33 = or i64 %32, 2
  %34 = getelementptr i32, ptr %.unpack92, i64 %33
  %wide.load110 = load <4 x i32>, ptr %34, align 4, !tbaa !3
  %35 = getelementptr i32, ptr %34, i64 4
  %wide.load111 = load <4 x i32>, ptr %35, align 4, !tbaa !3
  %36 = sub <4 x i32> %wide.load110, %wide.load
  %37 = sub <4 x i32> %wide.load111, %wide.load107
  %38 = mul <4 x i32> %36, %29
  %39 = mul <4 x i32> %37, %30
  %40 = icmp sgt <4 x i32> %38, zeroinitializer
  %41 = icmp sgt <4 x i32> %39, zeroinitializer
  %42 = zext <4 x i1> %40 to <4 x i32>
  %43 = zext <4 x i1> %41 to <4 x i32>
  %44 = add <4 x i32> %vec.phi, %42
  %45 = add <4 x i32> %vec.phi106, %43
  %index.next = add nuw i64 %index, 8
  %46 = icmp eq i64 %index.next, %n.vec
  br i1 %46, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %45, %44
  %47 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.scevcheck, %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 2, %vector.scevcheck ], [ 2, %.lr.ph ], [ %ind.end, %middle.block ]
  %.0104.ph = phi i32 [ 0, %vector.scevcheck ], [ 0, %.lr.ph ], [ %47, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.0104 = phi i32 [ %spec.select, %scalar.ph ], [ %.0104.ph, %scalar.ph.preheader ]
  %48 = add i64 %indvars.iv, -1
  %49 = getelementptr i32, ptr %.unpack92, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !3
  %51 = add i64 %indvars.iv, -2
  %52 = getelementptr i32, ptr %.unpack92, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !3
  %54 = sub i32 %50, %53
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %55 = ashr exact i64 %sext, 32
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %.unpack92, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !3
  %59 = sub i32 %58, %50
  %60 = mul i32 %59, %54
  %61 = icmp sgt i32 %60, 0
  %62 = zext i1 %61 to i32
  %spec.select = add i32 %.0104, %62
  %exitcond.not = icmp eq i64 %indvars.iv, %17
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %47, %middle.block ], [ %spec.select, %scalar.ph ]
  %63 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.366a6debfe6d6ab8987e975c64b75146, i32 13)
  %64 = call i1 @_FortranAioOutputInteger32(ptr %63, i32 %.0.lcssa)
  %65 = call i32 @_FortranAioEndIoStatement(ptr %63)
  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

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

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) }
attributes #2 = { 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, !10}
