#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<long long int> v;
vector<long long int> adj[300001];
bool visited[300001];
long long int dist[300001];
void bigger_right() {
  stack<pair<long long int, long long int> > s;
  for (long long int i = n - 1; i >= 0; i--) {
    while (!s.empty() && s.top().first < v[i]) s.pop();
    if (!s.empty()) adj[i].push_back(s.top().second);
    s.push({v[i], i});
  }
}
void smaller_right() {
  stack<pair<long long int, long long int> > s;
  for (long long int i = n - 1; i >= 0; i--) {
    while (!s.empty() && s.top().first > v[i]) s.pop();
    if (!s.empty()) adj[i].push_back(s.top().second);
    s.push({v[i], i});
  }
}
void bigger_left() {
  stack<pair<long long int, long long int> > s;
  for (long long int i = 0; i < n; i++) {
    while (!s.empty() && s.top().first < v[i]) s.pop();
    if (!s.empty()) adj[s.top().second].push_back(i);
    s.push({v[i], i});
  }
}
void smaller_left() {
  stack<pair<long long int, long long int> > s;
  for (long long int i = 0; i < n; i++) {
    while (!s.empty() && s.top().first > v[i]) s.pop();
    if (!s.empty()) adj[s.top().second].push_back(i);
    s.push({v[i], i});
  }
}
void bfs(long long int s) {
  dist[s] = 0;
  queue<long long int> q;
  q.push(s);
  while (!q.empty()) {
    long long int v = q.front();
    q.pop();
    if (visited[v]) continue;
    visited[v] = true;
    for (auto const &u : adj[v]) {
      if (dist[u] > dist[v] + 1) {
        dist[u] = dist[v] + 1;
        q.push(u);
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  v.resize(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  for (long long int i = 0; i < n; i++) dist[i] = INT_MAX;
  bigger_right();
  smaller_right();
  bigger_left();
  smaller_left();
  bfs(0);
  cout << dist[n - 1] << endl;
}
