#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    map<int,int>m;
    for(int i=0;i<n;i++){
        int v;
        cin>>v;
        m[v]++;
    }
    int ans=0;
    for(auto [x,y]:m){
        int now=m[x],la=m[x-1];
        ans+=max(now-la,0);
    }
    cout<<ans<<endl;
}