#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
using namespace std;
const long long maxn = 3e5 + 100;
long long t, n;
long long h[maxn], dp[maxn];
signed main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (auto i = (1); i <= (n); i++) {
    cin >> h[i];
    dp[i] = i;
  }
  dp[1] = 0;
  stack<long long> up, down;
  up.push(1), down.push(1);
  for (auto 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;
}
