#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
template <typename T>
void Out(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Out(x / 10);
  putchar(x % 10 + '0');
}
const int N = 2e5 + 10, MOD = 1e9 + 7, inf = 0x3f3f3f3f;
signed main() {
  int n;
  cin >> n;
  vector<int> a(n), dp(n);
  for (int i = 0; i <= n - 1; i++) cin >> a[i], dp[i] = i;
  stack<int> up, down;
  up.push(0);
  down.push(0);
  for (int i = 1; i <= n - 1; i++) {
    dp[i] = dp[i - 1] + 1;
    while (!down.empty() && a[i] >= a[down.top()]) {
      int x = a[down.top()];
      down.pop();
      if (a[i] > x && !down.empty()) dp[i] = min(dp[i], dp[down.top()] + 1);
    }
    down.push(i);
    while (!up.empty() && a[i] <= a[up.top()]) {
      int x = a[up.top()];
      up.pop();
      if (a[i] < x && !up.empty()) dp[i] = min(dp[i], dp[up.top()] + 1);
    }
    up.push(i);
  }
  cout << dp[n - 1] << "\n";
  return 0;
}
