#include <bits/stdc++.h>
using namespace std;
int T, n;
int ar[300005];
int ans[300005];
int sz[2];
int st[2][300005];
int tree[2][4 * 300005];
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
}
void solve() {
  st[0][++sz[0]] = n;
  st[1][++sz[1]] = n;
  for (int i = n - 1; i >= 1; i--) {
    ans[i] = INT_MAX;
    bool isSame;
    isSame = false;
    while (sz[0] && ar[i] >= ar[st[0][sz[0]]]) {
      int idx = st[0][sz[0]];
      ans[i] = min(ans[i], ans[idx] + 1);
      if (ar[i] == ar[idx]) isSame = true;
      sz[0]--;
    }
    if (sz[0] && !isSame) {
      int idx = st[0][sz[0]];
      ans[i] = min(ans[i], ans[idx] + 1);
    }
    isSame = false;
    while (sz[1] && ar[i] <= ar[st[1][sz[1]]]) {
      int idx = st[1][sz[1]];
      ans[i] = min(ans[i], ans[idx] + 1);
      if (ar[i] == ar[idx]) isSame = true;
      sz[1]--;
    }
    if (sz[1] && !isSame) {
      int idx = st[1][sz[1]];
      ans[i] = min(ans[i], ans[idx] + 1);
    }
    st[0][++sz[0]] = i;
    st[1][++sz[1]] = i;
  }
}
void output() { printf("%d\n", ans[1]); }
int main() {
  T = 1;
  for (int tc = 1; tc <= T; tc++) {
    input();
    solve();
    output();
  }
  return 0;
}
