#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define siz(v) ((int)(v).size())
#define all(v) begin((v)), end(v)
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) (1LL << (i))
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define dbg(x) "[" #x " = " << x << "]"
#define lli pair<long long, int>
using namespace std;
const int MAXN = 2e5 + 5, MAXK = 4, infINT = 5e6, mod = 998244353, MAXV = 1e6 + 6;
bool M1;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}
void add(int &a, const int &b){
a += b;
if (a >= mod) a -= mod;
}
void sub(int &a, const int &b){
a -= b;
if (a < 0) a += mod;
}
int mul(const int &a, const int &b){
return 1LL * a * 1LL * b % mod;
}
int bin_pow(int a, int k){
int res = 1;
while(k){
if (k & 1) res = mul(res, a);
k >>= 1; a = mul(a, a);
}
return res;
}
struct fenwickTree{
int n;
vector<int > bit;
fenwickTree(int _n = 0): n(_n){
bit.assign(n + 1, MAXV);
}
void update(int pos, const int &v){
for(; pos > 0; pos ^= pos & -pos) bit[pos] = min(bit[pos], v);
}
int get(int pos){
int mi = MAXV;
for(; pos <= n; pos += pos & -pos) mi = min(bit[pos], mi);
return mi;
}
};
int numVal, val[MAXN];
void input(){
cin >> numVal;
for(int i = 1; i <= numVal; i++) cin >> val[i];
}
void solve(){
fenwickTree bit(MAXV);
int cur = 1, res = 0;
while(cur <= numVal){
int nxt = cur + 1;
while(nxt <= numVal && val[nxt] >= val[nxt - 1] && bit.get(val[cur]) > val[nxt]){
nxt++;
}
res++;
bit.update(val[nxt - 1], val[nxt - 1]);
cur = nxt;
}
cout << res << '\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int t = 1;
// cin >> t;
while(t--){
input();
solve();
}
cerr << TIME << ".s\n";
}