#include <stdio.h>
typedef long long Int;
Int sign(Int a, Int b) {
    return a < b ? 1 : a > b ? -1 : 0;
}
int main() {
    Int n;
    scanf("%lld", &n);
    if (n == 1) {
        puts("1");
        return 0;
    }
    Int prev_num;
    Int prev_sign = 0;
    Int ans = 1;
    for (Int i = 0; i < n; i++) {
        Int a;
        scanf("%lld", &a);
        if (i > 0) {
            Int current_sign = sign(prev_num, a);
            if (i == 1) {
                prev_sign = current_sign;
            } else if (current_sign != 0) {
                if (current_sign != prev_sign) {
                    if (prev_sign != 0) {
                        ans++;
                        prev_sign = 0;
                    } else {
                        prev_sign = current_sign;
                    }
                }
            }
        }
        prev_num = a;
    }
    printf("%lld\n", ans);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_803/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_803/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 [5 x i8] c"%lld\00", align 1
@.str.1 = private unnamed_addr constant [2 x i8] c"1\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local i64 @sign(i64 noundef %a, i64 noundef %b) local_unnamed_addr #0 {
entry:
  %cmp = icmp slt i64 %a, %b
  %cmp1 = icmp sgt i64 %a, %b
  %0 = sext i1 %cmp1 to i64
  %cond2 = select i1 %cmp, i64 1, i64 %0
  ret i64 %cond2
}

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
  %n = alloca i64, align 8
  %a = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #4
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
  %0 = load i64, ptr %n, align 8, !tbaa !5
  %cmp = icmp eq i64 %0, 1
  br i1 %cmp, label %if.then, label %for.cond.preheader

for.cond.preheader:                               ; preds = %entry
  %cmp232 = icmp sgt i64 %0, 0
  br i1 %cmp232, label %if.end20.peel, label %for.cond.cleanup

if.end20.peel:                                    ; preds = %for.cond.preheader
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #4
  %call3.peel = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
  %.pre = load i64, ptr %a, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #4
  %1 = load i64, ptr %n, align 8, !tbaa !5
  %cmp2.peel = icmp sgt i64 %1, 1
  br i1 %cmp2.peel, label %if.end20.peel55, label %for.cond.cleanup

if.end20.peel55:                                  ; preds = %if.end20.peel
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #4
  %call3.peel39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
  %2 = load i64, ptr %a, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #4
  %3 = load i64, ptr %n, align 8, !tbaa !5
  %cmp2.peel59 = icmp sgt i64 %3, 2
  br i1 %cmp2.peel59, label %if.else.preheader, label %for.cond.cleanup

if.else.preheader:                                ; preds = %if.end20.peel55
  %cmp.i.peel42 = icmp slt i64 %.pre, %2
  %cmp1.i.peel43 = icmp sgt i64 %.pre, %2
  %4 = sext i1 %cmp1.i.peel43 to i64
  %cond2.i.peel44 = select i1 %cmp.i.peel42, i64 1, i64 %4
  br label %if.else

if.then:                                          ; preds = %entry
  %call1 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %cleanup

for.cond.cleanup:                                 ; preds = %if.else, %if.end20.peel, %if.end20.peel55, %for.cond.preheader
  %ans.0.lcssa = phi i64 [ 1, %for.cond.preheader ], [ 1, %if.end20.peel ], [ 1, %if.end20.peel55 ], [ %ans.2, %if.else ]
  %call22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %ans.0.lcssa)
  br label %cleanup

if.else:                                          ; preds = %if.else.preheader, %if.else
  %i.036 = phi i64 [ %inc21, %if.else ], [ 2, %if.else.preheader ]
  %ans.035 = phi i64 [ %ans.2, %if.else ], [ 1, %if.else.preheader ]
  %prev_sign.034 = phi i64 [ %prev_sign.2, %if.else ], [ %cond2.i.peel44, %if.else.preheader ]
  %prev_num.033 = phi i64 [ %5, %if.else ], [ %2, %if.else.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #4
  %call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
  %5 = load i64, ptr %a, align 8, !tbaa !5
  %cmp.i = icmp slt i64 %prev_num.033, %5
  %cmp1.i = icmp sgt i64 %prev_num.033, %5
  %6 = sext i1 %cmp1.i to i64
  %cond2.i = select i1 %cmp.i, i64 1, i64 %6
  %cmp9.not = icmp ne i64 %prev_num.033, %5
  %cmp11.not = icmp ne i64 %cond2.i, %prev_sign.034
  %or.cond.not = select i1 %cmp9.not, i1 %cmp11.not, i1 false
  %cmp13.not = icmp ne i64 %prev_sign.034, 0
  %spec.select = select i1 %cmp13.not, i64 0, i64 %cond2.i
  %prev_sign.2 = select i1 %or.cond.not, i64 %spec.select, i64 %prev_sign.034
  %narrow = select i1 %or.cond.not, i1 %cmp13.not, i1 false
  %spec.select31 = zext i1 %narrow to i64
  %ans.2 = add nuw nsw i64 %ans.035, %spec.select31
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #4
  %inc21 = add nuw nsw i64 %i.036, 1
  %7 = load i64, ptr %n, align 8, !tbaa !5
  %cmp2 = icmp slt i64 %inc21, %7
  br i1 %cmp2, label %if.else, label %for.cond.cleanup, !llvm.loop !9

cleanup:                                          ; preds = %for.cond.cleanup, %if.then
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #4
  ret i32 0
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!"long long", !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}
