#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
constexpr int inf = 1e9;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
set<int> l, r;
l.insert(0);
r.insert(inf);
int ans = 0, pos = 0;
for (; pos < n; pos++) {
ans++;
int x = *prev(l.upper_bound(a[pos]));
int y = *r.upper_bound(a[pos]);
l.insert(a[pos]);
r.insert(a[pos]);
while (pos + 1 < n && a[pos + 1] >= a[pos]) {
if (x <= a[pos + 1] && a[pos + 1] <= y) {
pos++;
l.insert(a[pos]);
r.insert(a[pos]);
} else {
break;
}
}
}
cout << ans << '\n';
return 0;
}