#include <bits/stdc++.h>
using namespace std;
int n, a;
int dp[300005];
vector<int> veze[300005];
int main() {
  cin >> n;
  vector<int> V;
  vector<pair<int, int>> V2;
  for (int i = 0; i < n; i++) {
    cin >> a;
    V.push_back(a);
  }
  V2.clear();
  for (int i = 0; i < n; i++) {
    while (!V2.empty() && V2.back().first <= V[i]) {
      veze[i].push_back(V2.back().second);
      V2.pop_back();
    }
    V2.push_back({V[i], i});
  }
  V2.clear();
  for (int i = 0; i < n; i++) {
    while (!V2.empty() && V2.back().first >= V[i]) {
      veze[i].push_back(V2.back().second);
      V2.pop_back();
    }
    V2.push_back({V[i], i});
  }
  V2.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (!V2.empty() && V2.back().first <= V[i]) {
      veze[V2.back().second].push_back(i);
      V2.pop_back();
    }
    V2.push_back({V[i], i});
  }
  V2.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (!V2.empty() && V2.back().first >= V[i]) {
      veze[V2.back().second].push_back(i);
      V2.pop_back();
    }
    V2.push_back({V[i], i});
  }
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    dp[i] = 1e9;
    for (auto e : veze[i]) {
      dp[i] = min(dp[i], dp[e] + 1);
    }
  }
  cout << dp[n - 1] << endl;
}
