#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define endl '\n'
template <class T>
using orderedSet =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void pipra(int tc) {
int n;
cin >> n;
vector<int> a(n);
orderedSet<ii> osR, osL;
// orderedSet<int> osL;
for(int i = 0 ; i < n ; i++) {
cin >> a[i];
osR.insert({a[i], i});
}
int ans = 0;
for(int i = 0 ; i < n ; i++) {
osR.erase({a[i], i});
int right = osR.size() - osR.order_of_key({a[i], i + 1});
int left = osL.order_of_key({a[i], i});
osL.insert({a[i], i});
if(left >= a[i] or right >= a[i])
ans++;
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1;
// cin >> t;
for(int i = 1 ; i <= t ; i++)
pipra(i);
return 0;
}