#include <bits/stdc++.h>
using namespace std;
int h[300000 + 5], dp[300000 + 5];
stack<int> minn, maxx;
bool eflg;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  dp[0] = 0;
  minn.push(0);
  maxx.push(0);
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1] + 1;
    eflg = 0;
    while (!minn.empty()) {
      int p = minn.top();
      if (h[p] >= h[i]) {
        if (!eflg) dp[i] = min(dp[i], dp[p] + 1);
        if (h[p] == h[i]) eflg = 1;
        minn.pop();
      } else
        break;
    }
    if (!minn.empty() && !eflg) dp[i] = min(dp[i], dp[minn.top()] + 1);
    minn.push(i);
    eflg = 0;
    while (!maxx.empty()) {
      int p = maxx.top();
      if (h[p] <= h[i]) {
        if (!eflg) dp[i] = min(dp[i], dp[p] + 1);
        if (h[p] == h[i]) eflg = 1;
        maxx.pop();
      } else
        break;
    }
    if (!maxx.empty() && !eflg) dp[i] = min(dp[i], dp[maxx.top()] + 1);
    maxx.push(i);
  }
  cout << dp[n - 1] << endl;
  return 0;
}
