#include <bits/stdc++.h>
using namespace std;
vector<int> order;
const int N = 3e5 + 5;
int answer[N], height[N], ll[N], lh[N], rl[N], rh[N], n;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> height[i];
    answer[i] = 1e9;
  }
  for (int i = 1; i <= n; i++) {
    ll[i] = i;
    while (!order.empty() && height[order.back()] > height[i]) order.pop_back();
    if (!order.empty()) ll[i] = order.back();
    order.push_back(i);
  }
  order.clear();
  for (int i = 1; i <= n; i++) {
    lh[i] = i;
    while (!order.empty() && height[order.back()] < height[i]) order.pop_back();
    if (!order.empty()) lh[i] = order.back();
    order.push_back(i);
  }
  order.clear();
  for (int i = n; i > 0; i--) {
    rl[i] = i;
    while (!order.empty() && height[order.back()] > height[i]) order.pop_back();
    if (!order.empty()) rl[i] = order.back();
    order.push_back(i);
  }
  order.clear();
  for (int i = n; i > 0; i--) {
    rh[i] = i;
    while (!order.empty() && height[order.back()] < height[i]) order.pop_back();
    if (!order.empty()) rh[i] = order.back();
    order.push_back(i);
  }
  answer[1] = 0;
  for (int i = 1; i <= n; i++) {
    answer[i] = min(answer[i], answer[i - 1] + 1);
    answer[i] = min(answer[i], answer[lh[i]] + 1);
    answer[i] = min(answer[i], answer[ll[i]] + 1);
    answer[rh[i]] = min(answer[rh[i]], answer[i] + 1);
    answer[rl[i]] = min(answer[rl[i]], answer[i] + 1);
  }
  cout << answer[n];
}
