#import <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a=0,b=0,c=0;
    int ans=0;
    for(int i=0;i<n;i++){
        a=b;
        b=c;
        scanf("%d",&c);
        if(i<=1) continue;
        if((a<b&&b<c)||(a>b&&b>c)) ans++;
    }
    printf("%d",ans);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_246/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_246/source.m"
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"

@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
  %n = alloca i32, align 4
  %c = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
  store i32 0, ptr %c, align 4, !tbaa !5
  %0 = load i32, ptr %n, align 4, !tbaa !5
  %cmp21 = icmp sgt i32 %0, 0
  br i1 %cmp21, label %for.inc.peel, label %for.cond.cleanup

for.inc.peel:                                     ; preds = %entry
  %call1.peel = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
  %1 = load i32, ptr %n, align 4, !tbaa !5
  %cmp.peel = icmp sgt i32 %1, 1
  br i1 %cmp.peel, label %for.inc.peel39, label %for.cond.cleanup

for.inc.peel39:                                   ; preds = %for.inc.peel
  %2 = load i32, ptr %c, align 4, !tbaa !5
  %call1.peel27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
  %3 = load i32, ptr %n, align 4, !tbaa !5
  %cmp.peel42 = icmp sgt i32 %3, 2
  br i1 %cmp.peel42, label %if.end, label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.inc, %for.inc.peel, %for.inc.peel39, %entry
  %ans.0.lcssa = phi i32 [ 0, %entry ], [ 0, %for.inc.peel ], [ 0, %for.inc.peel39 ], [ %ans.1, %for.inc ]
  %call11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %ans.0.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
  ret i32 0

if.end:                                           ; preds = %for.inc.peel39, %for.inc
  %i.024 = phi i32 [ %inc10, %for.inc ], [ 2, %for.inc.peel39 ]
  %ans.023 = phi i32 [ %ans.1, %for.inc ], [ 0, %for.inc.peel39 ]
  %b.022 = phi i32 [ %4, %for.inc ], [ %2, %for.inc.peel39 ]
  %4 = load i32, ptr %c, align 4, !tbaa !5
  %call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
  %cmp3 = icmp slt i32 %b.022, %4
  %5 = load i32, ptr %c, align 4
  %cmp4 = icmp slt i32 %4, %5
  %or.cond = select i1 %cmp3, i1 %cmp4, i1 false
  br i1 %or.cond, label %if.then8, label %lor.lhs.false

lor.lhs.false:                                    ; preds = %if.end
  %cmp5 = icmp sgt i32 %b.022, %4
  %cmp7 = icmp sgt i32 %4, %5
  %or.cond20 = select i1 %cmp5, i1 %cmp7, i1 false
  br i1 %or.cond20, label %if.then8, label %for.inc

if.then8:                                         ; preds = %lor.lhs.false, %if.end
  %inc = add nsw i32 %ans.023, 1
  br label %for.inc

for.inc:                                          ; preds = %lor.lhs.false, %if.then8
  %ans.1 = phi i32 [ %inc, %if.then8 ], [ %ans.023, %lor.lhs.false ]
  %inc10 = add nuw nsw i32 %i.024, 1
  %6 = load i32, ptr %n, align 4, !tbaa !5
  %cmp = icmp slt i32 %inc10, %6
  br i1 %cmp, label %if.end, label %for.cond.cleanup, !llvm.loop !9
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.peeled.count", i32 2}
