#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
int h[N], f[N];
int s1[N], s2[N], t1, t2;
void cmin(int &x, int y) { y < x && (x = y); }
int main() {
  memset(f, 63, sizeof(f));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  s1[t1 = 1] = s2[t2 = 1] = 1, f[1] = 0;
  for (int i = 2; i <= n; i++) {
    f[i] = f[i - 1] + 1;
    for (; t1 && h[s1[t1]] > h[i]; cmin(f[i], f[s1[t1--]] + 1))
      ;
    for (; t2 && h[s2[t2]] < h[i]; cmin(f[i], f[s2[t2--]] + 1))
      ;
    cmin(f[i], min(f[s1[t1]], f[s2[t2]]) + 1);
    for (; t1 && h[s1[t1]] == h[i]; t1--)
      ;
    for (; t2 && h[s2[t2]] == h[i]; t2--)
      ;
    s1[++t1] = s2[++t2] = i;
  }
  printf("%d\n", f[n]);
}
