#include<bits/stdc++.h>
#define ll long long
#define nl '\n'
#define F first
#define S second
#define all(a) (a.begin()),(a.end())
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define ms(a,b) memset(a, b, sizeof(a))
#define Input freopen("in.txt","r",stdin)
#define Output freopen("out.txt","w",stdout)
#define MOD 1000000007
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T> using orderset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 2e5 + 5;
ll a[N], b[N];
void Solve(int t)
{
ll n;
cin >> n;
orderset<ll> s;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (s.size() >= a[i]) {
ll x = s.order_of_key(a[i] - 1);
if (x <= a[i])
b[i]++;
}
s.insert(a[i]);
}
s.clear();
for (int i = n; i >= 1; i--)
{
if (s.size() >= a[i]) {
ll j = s.size() - a[i];
ll x = s.order_of_key(j);
if (x >= a[i])
b[i]++;
}
s.insert(a[i]);
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
// cout << b[i] << ' ';
if (b[i] > 0)
ans++;
}
// cout << endl;
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t, T = 1;
// cin >> T;
for (t = 1; t <= T; t++)
Solve(t);
return 0;
}