#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
struct segtree {
  int n;
  vector<int> t;
  segtree(int _n) {
    n = _n;
    t.resize(4 * _n, INF);
  }
  void upd(int v, int l, int r, int L, int R, int x) {
    if (l >= R || L >= r) {
      return;
    }
    if (L <= l && r <= R) {
      t[v] = x;
      return;
    }
    upd(v * 2, l, (l + r) / 2, L, R, x);
    upd(v * 2 + 1, (l + r) / 2, r, L, R, x);
    t[v] = min(t[v * 2], t[v * 2 + 1]);
  }
  int get(int v, int l, int r, int L, int R) {
    if (l >= R || L >= r) {
      return INF;
    }
    if (L <= l && r <= R) {
      return t[v];
    }
    return min(get(v * 2, l, (l + r) / 2, L, R),
               get(v * 2 + 1, (l + r) / 2, r, L, R));
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> v1(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    v1[i] = -v[i];
  }
  vector<int> l(n, -1);
  vector<int> l1(n, -1);
  vector<int> r(n, n);
  vector<int> r1(n, n);
  vector<int> cur;
  vector<int> cur1;
  for (int i = n - 1; i >= 0; --i) {
    while (!cur.empty() && v[i] < v[cur.back()]) {
      cur.pop_back();
    }
    while (!cur1.empty() && v1[i] < v1[cur1.back()]) {
      cur1.pop_back();
    }
    if (!cur.empty()) {
      r[i] = cur.back();
    }
    if (!cur1.empty()) {
      r1[i] = cur1.back();
    }
    cur.push_back(i);
    cur1.push_back(i);
  }
  cur.clear();
  cur1.clear();
  vector<int> dp(n);
  segtree a(n), b(n);
  set<pair<int, int>> to_del;
  set<pair<int, int>> to_del1;
  for (int i = 0; i < n; ++i) {
    while (!to_del.empty() && to_del.begin()->first < i) {
      a.upd(1, 0, n, to_del.begin()->second, to_del.begin()->second + 1, INF);
      to_del.erase(to_del.begin());
    }
    while (!to_del1.empty() && to_del1.begin()->first < i) {
      b.upd(1, 0, n, to_del1.begin()->second, to_del1.begin()->second + 1, INF);
      to_del1.erase(to_del1.begin());
    }
    while (!cur.empty() && v[i] < v[cur.back()]) {
      cur.pop_back();
    }
    while (!cur1.empty() && v1[i] < v1[cur1.back()]) {
      cur1.pop_back();
    }
    if (!cur.empty()) {
      l[i] = cur.back();
    }
    if (!cur1.empty()) {
      l1[i] = cur1.back();
    }
    if (i > 0)
      dp[i] = min(a.get(1, 0, n, max(0, l[i]), i),
                  b.get(1, 0, n, max(0, l1[i]), i)) +
              1;
    to_del.insert({r[i], i});
    to_del1.insert({r1[i], i});
    if (i > 0) {
      dp[i] = min(dp[i - 1] + 1, dp[i]);
    }
    a.upd(1, 0, n, i, i + 1, dp[i]);
    b.upd(1, 0, n, i, i + 1, dp[i]);
    cur.push_back(i);
    cur1.push_back(i);
  }
  cout << dp[n - 1];
}
