1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from sys import stdin, stdout

n = int(stdin.readline())
trel_list = [int(x) for x in stdin.readline().strip().split(" ")]

MAX = 10**6
result = n

for sgn in [-1, 1]:
    prev = (-1) * MAX * sgn
    part_result = 0
    for trel in trel_list:
        if (sgn * trel <= sgn * prev):
            part_result += 1
            prev = sgn * MAX
        else:
            prev = trel
        sgn = 0 - sgn
    result = min(result, part_result)

stdout.write(str(result)+"\n")