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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
     
using namespace std;
     
#define turbo cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define inf 1999999999
#define biginf 199999999999999999
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define f first
#define s second
#define int long long


signed main() {
	turbo;
	int n;
	cin >> n;
	vector <int> input(n);
	for(int i = 0; i < n; i++)
		cin >> input[i];
	int res = 0;
	vector <int> copy = input;
	for (int i = 1; i < n; i++) {
		if (i % 2 == 1 && input[i] > input[i - 1])
			continue;
		if (i % 2 == 0 && input[i] < input[i - 1])
			continue;
		if (i % 2 == 1)
			input[i] = inf;
		else
			input[i] = -inf;
		res++;
	}
	int res2 = 0;
	for (int i = 1; i < n; i++) {
		if (i % 2 == 1 && copy[i] < copy[i - 1])
			continue;
		if (i % 2 == 0 && copy[i] > copy[i - 1])
			continue;
		if (i % 2 == 1)
			copy[i] = -inf;
		else
			copy[i] = inf;
		res2++;
	}
	cout << min(res, res2) << "\n";
	return 0;
}