#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(nullptr));
inline void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
const long long inf = 2e9;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; ++i) {
    cin >> v[i];
  }
  vector<long long> st;
  vector<vector<long long> > g(n);
  for (long long i = n - 1; i >= 0; --i) {
    while (st.size() > 0 && v[st.back()] < v[i]) {
      st.pop_back();
    }
    if (st.size() > 0) g[i].push_back(st.back());
    st.push_back(i);
  }
  st.clear();
  for (long long i = n - 1; i >= 0; --i) {
    while (st.size() > 0 && v[st.back()] > v[i]) {
      st.pop_back();
    }
    if (st.size() > 0) g[i].push_back(st.back());
    st.push_back(i);
  }
  st.clear();
  for (long long i = 0; i < n; ++i) {
    while (st.size() > 0 && v[st.back()] > v[i]) {
      st.pop_back();
    }
    if (st.size() > 0) {
      g[st.back()].push_back(i);
    }
    st.push_back(i);
  }
  st.clear();
  for (long long i = 0; i < n; ++i) {
    while (st.size() > 0 && v[st.back()] < v[i]) {
      st.pop_back();
    }
    if (st.size() > 0) {
      g[st.back()].push_back(i);
    }
    st.push_back(i);
  }
  vector<long long> dp(n, inf);
  dp[0] = 0;
  for (long long i = 0; i < n - 1; ++i) {
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    for (auto j : g[i]) {
      dp[j] = min(dp[j], dp[i] + 1);
    }
  }
  cout << dp.back() << '\n';
}
signed main() {
  fastio();
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
