#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  std::vector<int> h(n + 1);
  for (long long int i = 0; i < n; i++) cin >> h[i + 1];
  long long int dp[n + 1];
  dp[1] = 0;
  for (int i = 2; i <= n; ++i) {
    dp[i] = INT_MAX;
  }
  std::vector<int> stack;
  std::vector<int> nextmax(n + 1);
  std::vector<int> nextmin(n + 1);
  std::vector<int> prevmax(n + 1);
  std::vector<int> prevmin(n + 1);
  std::vector<std::vector<int>> poss(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    while (!stack.empty() && h[i + 1] >= h[stack.back()]) {
      prevmax[stack.back()] = i + 1;
      stack.pop_back();
    }
    stack.push_back(i + 1);
  }
  while (!stack.empty()) {
    prevmax[stack.back()] = 0;
    stack.pop_back();
  }
  for (int i = n - 1; i >= 0; i--) {
    while (!stack.empty() && h[i + 1] <= h[stack.back()]) {
      prevmin[stack.back()] = i + 1;
      stack.pop_back();
    }
    stack.push_back(i + 1);
  }
  while (!stack.empty()) {
    prevmin[stack.back()] = 0;
    stack.pop_back();
  }
  for (long long int i = 0; i < n; i++) {
    while (!stack.empty() && h[i + 1] >= h[stack.back()]) {
      nextmax[stack.back()] = i + 1;
      stack.pop_back();
    }
    stack.push_back(i + 1);
  }
  while (!stack.empty()) {
    nextmax[stack.back()] = n + 1;
    stack.pop_back();
  }
  for (long long int i = 0; i < n; i++) {
    while (!stack.empty() && h[i + 1] <= h[stack.back()]) {
      nextmin[stack.back()] = i + 1;
      stack.pop_back();
    }
    stack.push_back(i + 1);
  }
  while (!stack.empty()) {
    nextmin[stack.back()] = n + 1;
    stack.pop_back();
  }
  for (long long int i = 0; i < n; i++) {
    if (nextmax[i + 1] != n + 1) poss[i + 1].push_back(nextmax[i + 1]);
    if (nextmin[i + 1] != n + 1) poss[i + 1].push_back(nextmin[i + 1]);
    if (prevmax[i + 1] != 0) poss[prevmax[i + 1]].push_back(i + 1);
    if (prevmin[i + 1] != 0) poss[prevmin[i + 1]].push_back(i + 1);
  }
  for (int i = 1; i <= n - 1; i++) {
    for (auto& j : poss[i]) {
      dp[j] = min(dp[j], dp[i] + 1);
    }
  }
  cout << dp[n] << "\n";
}
