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
from itertools import tee

_ = input()
vals = list(map(int, input().split()))

def compare(a, b):
    if a == b:
        return -1
    return a > b

def check(vals, start):
    r = 0
    i = start
    a, b = tee(vals)
    next(b, None)
    it = zip(a, b)
    for a, b in it:
        if i % 2 != compare(a, b):
            r += 1
            next(it, None)
        else:
            i += 1
    return r

print(min(check(vals, 0), check(vals, 1)))