#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int a[maxn];
int s1[maxn], s2[maxn], p1, p2;
int f[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(f, 0x3f, sizeof(f));
  f[1] = 0;
  s1[++p1] = 1, s2[++p2] = 1;
  for (int i = 2; i <= n; i++) {
    f[i] = min(f[i], f[i - 1] + 1);
    bool flag = true;
    while (p1 && a[i] <= a[s1[p1]]) {
      if (a[s1[p1]] == a[i]) flag = false;
      f[i] = min(f[i], f[s1[p1]] + 1), p1--;
    }
    if (flag) f[i] = min(f[i], f[s1[p1]] + 1);
    flag = true;
    while (p2 && a[i] >= a[s2[p2]]) {
      if (a[s2[p2]] == a[i]) flag = false;
      f[i] = min(f[i], f[s2[p2]] + 1), p2--;
    }
    if (flag) f[i] = min(f[i], f[s2[p2]] + 1);
    s1[++p1] = i, s2[++p2] = i;
  }
  cout << f[n] << endl;
  return 0;
}
