#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
long long h[maxn], dp[maxn];
int main(void) {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> h[i];
  }
  for (long long i = 1; i <= n; i++) dp[i] = i;
  dp[1] = 0;
  stack<long long> up, down;
  up.push(1);
  down.push(1);
  for (long long i = 2; i <= n; i++) {
    dp[i] = dp[i - 1] + 1;
    while (down.size() && h[i] >= h[down.top()]) {
      long long x = h[down.top()];
      down.pop();
      if (h[i] > x && down.size()) {
        dp[i] = min(dp[i], dp[down.top()] + 1);
      }
    }
    down.push(i);
    while (up.size() && h[i] <= h[up.top()]) {
      long long x = h[up.top()];
      up.pop();
      if (h[i] < x && up.size()) {
        dp[i] = min(dp[i], dp[up.top()] + 1);
      }
    }
    up.push(i);
  }
  cout << dp[n] << endl;
  return 0;
}
