1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
zp=0
zm=0
m=10**9
ap=a[0]
am=a[0]
for i in range(1,n):
    if i%2==1:
        if a[i]<=ap:
            zp+=1
            ap=m
        else:
            ap=a[i]
        if a[i]>=am:
            zm+=1
            am=-m
        else:
            am=a[i]
    else:
        if a[i]>=ap:
            zp+=1
            ap=-m
        else:
            ap=a[i]
        if a[i]<=am:
            zm+=1
            am=m
        else:
            am=a[i]
print(min(zp,zm))