#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll MOD = 1000 * 1000 * 1000 + 7;
constexpr int ALPHABET_SIZE = 26;
constexpr ll INF = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> dp(n);
  stack<pair<int, int>> s_min, s_max;
  s_min.emplace(h[0], 0);
  s_max.emplace(h[0], 0);
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1] + 1;
    bool have_eq = false;
    while (!s_max.empty() && s_max.top().first <= h[i]) {
      if (h[i - 1] < h[i]) {
        dp[i] = min(dp[i], s_max.top().second + 1);
      }
      if (s_max.top().first == h[i]) {
        have_eq = true;
      }
      s_max.pop();
    }
    if (h[i - 1] < h[i] && !have_eq && !s_max.empty()) {
      dp[i] = min(dp[i], s_max.top().second + 1);
    }
    have_eq = false;
    while (!s_min.empty() && s_min.top().first >= h[i]) {
      if (h[i - 1] > h[i]) {
        dp[i] = min(dp[i], s_min.top().second + 1);
      }
      if (s_min.top().first == h[i]) {
        have_eq = true;
      }
      s_min.pop();
    }
    if (h[i - 1] > h[i] && !have_eq && !s_min.empty()) {
      dp[i] = min(dp[i], s_min.top().second + 1);
    }
    s_max.emplace(h[i], dp[i]);
    s_min.emplace(h[i], dp[i]);
  }
  cout << dp[n - 1] << "\n";
  return 0;
}
