#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  stack<int> s_less, s_great;
  int less[n], great[n];
  less[0] = -1;
  great[0] = -1;
  s_less.push(0);
  s_great.push(0);
  for (int i = 1; i < n; i++) {
    while (!s_great.empty()) {
      int ind = s_great.top();
      if (a[ind] < a[i]) {
        s_great.pop();
      } else {
        break;
      }
    }
    if (s_great.empty()) {
      great[i] = -1;
    } else {
      great[i] = s_great.top();
    }
    s_great.push(i);
    while (!s_less.empty()) {
      int ind = s_less.top();
      if (a[ind] > a[i]) {
        s_less.pop();
      } else {
        break;
      }
    }
    if (s_less.empty()) {
      less[i] = -1;
    } else {
      less[i] = s_less.top();
    }
    s_less.push(i);
  }
  stack<int> s_less_right, s_great_right;
  int less_right[n], great_right[n];
  less_right[n - 1] = -1;
  great_right[n - 1] = -1;
  s_less_right.push(n - 1);
  s_great_right.push(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    while (!s_great_right.empty()) {
      int ind = s_great_right.top();
      if (a[ind] < a[i]) {
        s_great_right.pop();
      } else {
        break;
      }
    }
    if (s_great_right.empty()) {
      great_right[i] = -1;
    } else {
      great_right[i] = s_great_right.top();
    }
    s_great_right.push(i);
    while (!s_less_right.empty()) {
      int ind = s_less_right.top();
      if (a[ind] > a[i]) {
        s_less_right.pop();
      } else {
        break;
      }
    }
    if (s_less_right.empty()) {
      less_right[i] = -1;
    } else {
      less_right[i] = s_less_right.top();
    }
    s_less_right.push(i);
  }
  int dist[n];
  for (int i = 0; i < n; i++) dist[i] = n;
  dist[0] = 0;
  for (int i = 0; i < n; i++) {
    if (less[i] != -1) {
      dist[i] = min(dist[less[i]] + 1, dist[i]);
    }
    if (great[i] != -1) {
      dist[i] = min(dist[great[i]] + 1, dist[i]);
    }
    if (less_right[i] != -1) {
      dist[less_right[i]] = min(dist[i] + 1, dist[less_right[i]]);
    }
    if (great_right[i] != -1) {
      dist[great_right[i]] = min(dist[i] + 1, dist[great_right[i]]);
    }
  }
  cout << dist[n - 1] << endl;
}
