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
#include <iostream>
#include <vector>
#define GET_VALUE(value_) (std::cin >> (value_))
#define ITR(container_, vname_) for (auto &vname_ : (container_))
#define GETT(type_, name_) for (type_ name_, name_##_marker_ = 1; name_##_marker_ && (GET_VALUE(name_), 1); --name_##_marker_)
#define GET(name_) GETT(int, name_)
#define DECL_GETT(type_, name_) \
  type_ name_;                  \
  GET_VALUE(name_)
#define DECL_GET(name_) DECL_GETT(int, name_)
#define PUTN(value_) std::cout << (value_)
#define PUT(value_) PUTN(value_) << "\n"
using namespace std;
#define V_MAX 1000000000
#define V_MIN -V_MAX
static int calculate(vector<int> const &v, int increase) {
  int result = 0;
  auto it = v.cbegin();
  int last = *it;
  while (++it != v.cend()) {
    int cur = *it;
    if (increase) {
      if (cur <= last) {
        ++result;
        cur = V_MAX;
      }
    } else {
      if (cur >= last) {
        ++result;
        cur = V_MIN;
      }
    }
    last = cur;
    increase ^= 1;
  }
  return result;
}
int main() {
  DECL_GET(n);
  vector<int> array(n);
  ITR(array, e)
  GET(v)
  e = v;
  int a = calculate(array, 0);
  int b = calculate(array, 1);
  PUT(min(a, b));
}