// Arup Guha
// 6/5/2026
// Solution to Kattis Problem: Baloni
// https://open.kattis.com/problems/baloni

using namespace std;
#include <bits/stdc++.h>

int main() {

    // Read in the number of arrows.
    int n, res = 0;
    cin >> n;

    // freq[i] = # of arrows at height i. I start with no arrows.
    vector<int> freq(1000001,0);

    for (int i=0; i<n; i++) {

        int arrow;
        cin >> arrow;

        // No arrow, add it, it lowers by 1 foot and keeps flying.
        if (freq[arrow] == 0) {
            res++;
            freq[arrow-1]++;
        }

        // No new arrow, this one pops the balloon and lowers.
        else {
            freq[arrow]--;
            freq[arrow-1]++;
        }

    }

    // Ta da!
    cout << res << endl;
    return 0;
}
