#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n;
int h[N], f[N];
int main() {
  cin >> n;
  stack<int> stk1, stk2;
  cin >> h[1];
  stk1.push(1), stk2.push(1);
  bool flag = 1;
  for (int i = 2; i <= n; i++) {
    cin >> h[i];
    f[i] = f[i - 1] + 1;
    bool flag = 1;
    while (stk1.size() && h[stk1.top()] >= h[i]) {
      f[i] = min(f[i], f[stk1.top()] + 1);
      if (h[i] == h[stk1.top()]) flag = 0;
      stk1.pop();
    }
    if (stk1.size() && flag) f[i] = min(f[i], f[stk1.top()] + 1);
    stk1.push(i);
    flag = 1;
    while (stk2.size() && h[stk2.top()] <= h[i]) {
      f[i] = min(f[i], f[stk2.top()] + 1);
      if (h[i] == h[stk2.top()]) flag = 0;
      stk2.pop();
    }
    if (stk2.size() && flag) f[i] = min(f[i], f[stk2.top()] + 1);
    stk2.push(i);
  }
  cout << f[n] << endl;
  return 0;
}
