#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<ll> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    // Sort initial rewards in decreasing order
    sort(a.begin(), a.end(), greater<ll>());

    /*
        prefix[i] =
        maximum value of:

            a[j] + (j + 1)

        for j <= i

        This represents the maximum final score
        among customers BEFORE the candidate.
    */
    vector<ll> prefix(n);

    for (int i = 0; i < n; i++) {

        ll value = a[i] + (i + 1);

        if (i == 0)
            prefix[i] = value;
        else
            prefix[i] = max(prefix[i - 1], value);
    }

    /*
        suffix[i] =
        maximum value of:

            a[j] + j

        for j >= i

        This represents the maximum final score
        among customers AFTER the candidate.
    */
    vector<ll> suffix(n);

    for (int i = n - 1; i >= 0; i--) {

        ll value = a[i] + i;

        if (i == n - 1)
            suffix[i] = value;
        else
            suffix[i] = max(suffix[i + 1], value);
    }

    int answer = 0;

    // Try every customer as the winner
    for (int i = 0; i < n; i++) {

        // Candidate wins and receives n tournament points
        ll candidateScore = a[i] + n;

        ll bestOtherScore = LLONG_MIN;

        // Customers before i
        if (i > 0) {
            bestOtherScore = max(
                bestOtherScore,
                prefix[i - 1]
            );
        }

        // Customers after i
        if (i + 1 < n) {
            bestOtherScore = max(
                bestOtherScore,
                suffix[i + 1]
            );
        }

        // Candidate has the highest score
        if (candidateScore >= bestOtherScore) {
            answer++;
        }
    }

    cout << answer << '\n';

    return 0;
}