1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
n = int(input())
a = list(map(int, input().split()))

def solve(l):
    dp = [0]
    dpI = [1]
    
    for i in range(n - 1):
        dpI.append(min(dp[i], dpI[i]) + 1)

        poss = [dpI[i]]

        if pow(-1, i % 2) * (l[i] - l[i + 1]) > 0:
            poss.append(dp[i])

        dp.append(min(poss))

    return min(dp[-1], dpI[-1])

print(min(solve(a), solve([-v for v in a])))