#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int a[maxn], dp[maxn];
int main() {
  int n;
  cin >> n;
  fill(dp, dp + 1 + n, INT_MAX);
  for (int i = 1; i <= n; i++) cin >> a[i];
  stack<int> up, down;
  dp[1] = 0;
  up.push(1);
  down.push(1);
  for (int i = 2; i <= n; i++) {
    dp[i] = min(dp[i], dp[i - 1] + 1);
    while (up.size() && a[up.top()] >= a[i]) {
      int x = a[up.top()];
      up.pop();
      if (up.size() && a[i] < x) {
        dp[i] = min(dp[i], dp[up.top()] + 1);
      }
    }
    while (down.size() && a[down.top()] <= a[i]) {
      int x = a[down.top()];
      down.pop();
      if (down.size() && a[i] > x) {
        dp[i] = min(dp[i], dp[down.top()] + 1);
      }
    }
    up.push(i), down.push(i);
  }
  cout << dp[n];
  return 0;
}
