stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



map<int, int> cnt;



int main()

{



    int n, x;



    scanf("%d", &n);



    int res = 0;



    while(n--){



        scanf("%d", &x);

        cnt[x]++;

    }



    for(map<int, int> ::iterator it = cnt.begin(); it!=cnt.end(); it++){



        int occ = it->second;



        int key = it->first;



        if(occ>key) res += (occ-key);

        else if(occ<key) res += occ;



    }



    cout<<res<<endl;







}


// Faster C++ solution for the same problem (measured speedup: 5.2501563110876175x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

map<int,int> mp,flag;



int main()

{

    int n;

    cin>>n;

    int a[n+2],ans=0;

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

    {

        cin>>a[i];

        mp[a[i]]++;

    }

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

    {

        if(flag[a[i]]) continue;

        if(mp[a[i]]<a[i]) ans+=mp[a[i]];

        else ans+=(mp[a[i]]-a[i]);

        flag[a[i]]=1;

    }

    cout<<ans<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.256338469513115x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 7.599090979642219x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;







map<int, int>mp;

int ara[100009];

int main()

{

	int n;

	scanf("%d",&n);



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

	{

		scanf("%d",&ara[i]);

		mp[ara[i]]++;

	}





	int tot=0;

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

	{

        int x=ara[i];



		if(mp[x]>=x)

        tot+= mp[x]-x;

        else

			tot+=mp[x];



        mp[x]=x;



	}





	printf("%d\n",tot);



}


// Faster C++ solution for the same problem (measured speedup: 5.230510167175989x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int cnt[100009];



int main()

{

    //cout<<cnt[1000000000]<<endl;



    int n;

    scanf("%d",&n);

    int a[100009];

    int uniq[100009];



    int i=0;

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

    {

        scanf("%d",&a[i]);

        //cnt[a[i]]++;

    }



    sort(a,a+n);

    int j =0;

    cnt[j]=1;

    uniq[j] = a[0];

    for( i=1; i<n; i++)

    {

        if(a[i]!=a[i-1])

        {

            j++;

            cnt[j]=1;

            uniq[j]=a[i];

        }

        else cnt[j]++;

    }

    int ans =0;

    i=0;

    for(int i=0; i<=j; i++)

    {

        if(cnt[i]<uniq[i]) ans+=cnt[i];

        else if(cnt[i]>uniq[i]) ans+= cnt[i]-uniq[i];

    }

    printf("%d\n",ans);

    //main();



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2965049280090435x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {



  //  freopen ("in.txt", "r", stdin);



    int n;

    cin >> n;



    map < long, long > cnt;



    long a[n];

    vector < long > lst;



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



        cin >> a[i];

        if(cnt[a[i]]==0) lst.push_back(a[i]);

        cnt[a[i]]++;

    }

    long lagbe = 0;

    for (int i=0; i<(int)lst.size(); i++) {

        int v = lst[i];

        if(v!=cnt[v]) {

            if(cnt[v]>v) {

                lagbe += cnt[v]-v;

            }

            else lagbe += cnt[v];

        }

    }



    cout << lagbe << endl;





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.293752095739992x):
#include<cstdio>

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

	for(register int i=1;i<=n;i++){

		scanf("%d",&a[i]);

	}

	int m=0;

	sort(a+1,a+n+1);

	for(register int i=1;i<=n;i++){

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

	for(register int i=1;i<=m;i++){

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

  for (int i = 0; i < 100001; ++i)

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

  for (int i = 1; i < 100001; ++i) {

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.494871863782727x):
#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

int n, a[maxn];

int cnt[maxn];

int ans = 0;

int main() {

	cin >> n;

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

		cin >> a[i];

		if(a[i] > n)

			ans++;

		else

			cnt[a[i]]++;

	}

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

		if(cnt[i] >= i)

			ans += cnt[i] - i;

		else

			ans += cnt[i];

	}

	cout << ans;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.4528515494429262x):
#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

int n, a[maxn];

int cnt[maxn];

int ans = 0;

int main() {

	cin >> n;

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

		cin >> a[i];

		if(a[i] > n)

			ans++;

		else

			cnt[a[i]]++;

	}

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

		if(cnt[i] >= i)

			ans += cnt[i] - i;

		else

			ans += cnt[i];

	}

	cout << ans;

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



	for (int i = 1; i < MAX_N; i++)

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.483658440036528x):
#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

int n, a[maxn];

int cnt[maxn];

int ans = 0;

int main() {

	cin >> n;

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

		cin >> a[i];

		if(a[i] > n)

			ans++;

		else

			cnt[a[i]]++;

	}

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

		if(cnt[i] >= i)

			ans += cnt[i] - i;

		else

			ans += cnt[i];

	}

	cout << ans;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

  for (int i = 0; i < 100001; ++i)

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

  for (int i = 1; i < 100001; ++i) {

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4888988586845595x):
#include <bits/stdc++.h>



using namespace std;



map<int,int> m;

int n;

int arr[100005];



int main()

{

	cin >> n;

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

	{

		cin >> arr[i];

		m[arr[i]]++;

	}

	int ans=0;

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

	{

		if(m[arr[i]]==-1) continue;

		if(m[arr[i]]<arr[i]) ans+=m[arr[i]];

		else ans+=m[arr[i]]-arr[i];

		m[arr[i]]=-1;

	}

	cout << ans << endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.4470464433853782x):
#include <bits/stdc++.h>



using namespace std;



map<int,int> m;

int n;

int arr[100005];



int main()

{

	cin >> n;

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

	{

		cin >> arr[i];

		m[arr[i]]++;

	}

	int ans=0;

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

	{

		if(m[arr[i]]==-1) continue;

		if(m[arr[i]]<arr[i]) ans+=m[arr[i]];

		else ans+=m[arr[i]]-arr[i];

		m[arr[i]]=-1;

	}

	cout << ans << endl;

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



	for (int i = 1; i < MAX_N; i++)

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.477730240007495x):
#include <bits/stdc++.h>



using namespace std;



map<int,int> m;

int n;

int arr[100005];



int main()

{

	cin >> n;

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

	{

		cin >> arr[i];

		m[arr[i]]++;

	}

	int ans=0;

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

	{

		if(m[arr[i]]==-1) continue;

		if(m[arr[i]]<arr[i]) ans+=m[arr[i]];

		else ans+=m[arr[i]]-arr[i];

		m[arr[i]]=-1;

	}

	cout << ans << endl;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

  for (int i = 0; i < 100001; ++i)

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

  for (int i = 1; i < 100001; ++i) {

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.492390157848048x):
/// However long the night,

///     The dawn will break

/// ICPC next year



#include<bits/stdc++.h>

using namespace std ;

const int N = 2e5+5 ;



int n ,x ;

long long ans ;

map<int,int> cnt ;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&x);

        ++cnt[x] ;

    }

    for(auto go:cnt){

        if(go.first>go.second) ans += go.second ;

        else ans += go.second - go.first ;

    }

    cout << ans ;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.4504396033759661x):
/// However long the night,

///     The dawn will break

/// ICPC next year



#include<bits/stdc++.h>

using namespace std ;

const int N = 2e5+5 ;



int n ,x ;

long long ans ;

map<int,int> cnt ;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&x);

        ++cnt[x] ;

    }

    for(auto go:cnt){

        if(go.first>go.second) ans += go.second ;

        else ans += go.second - go.first ;

    }

    cout << ans ;

    return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



	for (int i = 1; i < MAX_N; i++)

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4811953500253494x):
/// However long the night,

///     The dawn will break

/// ICPC next year



#include<bits/stdc++.h>

using namespace std ;

const int N = 2e5+5 ;



int n ,x ;

long long ans ;

map<int,int> cnt ;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&x);

        ++cnt[x] ;

    }

    for(auto go:cnt){

        if(go.first>go.second) ans += go.second ;

        else ans += go.second - go.first ;

    }

    cout << ans ;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

  for (int i = 0; i < 100001; ++i)

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

  for (int i = 1; i < 100001; ++i) {

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4586635386905389x):
//

// Created by Mahmoud Rashad on 11/27/19.

//



#include <bits/stdc++.h>





using namespace std;



typedef vector<int> vi;

typedef pair<int, int> ii;

typedef vector<pair<ii, ii>> vii;



int main() {

#ifndef ONLINE_JUDGE

//    freopen("input.txt", "r", stdin);

//    freopen("output.out", "w", stdout);

#endif

    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;



    int n;

    cin >> n;

    map<int, int> mp;

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

        int x;

        cin >> x;

        mp[x]++;

    }



    int ans = 0;

    for (auto it : mp) {

        if (it.second >= it.first)

            ans += it.second - it.first;

        else

            ans += it.second;

    }



    cout << ans << '\n';



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.4176610274407242x):
//

// Created by Mahmoud Rashad on 11/27/19.

//



#include <bits/stdc++.h>





using namespace std;



typedef vector<int> vi;

typedef pair<int, int> ii;

typedef vector<pair<ii, ii>> vii;



int main() {

#ifndef ONLINE_JUDGE

//    freopen("input.txt", "r", stdin);

//    freopen("output.out", "w", stdout);

#endif

    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;



    int n;

    cin >> n;

    map<int, int> mp;

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

        int x;

        cin >> x;

        mp[x]++;

    }



    int ans = 0;

    for (auto it : mp) {

        if (it.second >= it.first)

            ans += it.second - it.first;

        else

            ans += it.second;

    }



    cout << ans << '\n';



    return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



	for (int i = 1; i < MAX_N; i++)

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.447721723034796x):
//

// Created by Mahmoud Rashad on 11/27/19.

//



#include <bits/stdc++.h>





using namespace std;



typedef vector<int> vi;

typedef pair<int, int> ii;

typedef vector<pair<ii, ii>> vii;



int main() {

#ifndef ONLINE_JUDGE

//    freopen("input.txt", "r", stdin);

//    freopen("output.out", "w", stdout);

#endif

    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;



    int n;

    cin >> n;

    map<int, int> mp;

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

        int x;

        cin >> x;

        mp[x]++;

    }



    int ans = 0;

    for (auto it : mp) {

        if (it.second >= it.first)

            ans += it.second - it.first;

        else

            ans += it.second;

    }



    cout << ans << '\n';



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

  for (int i = 0; i < 100001; ++i)

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

  for (int i = 1; i < 100001; ++i) {

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4778381116065127x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int n,x;

    vector<long long int>v;

    map<long long int,long long int>m;

    cin>>n;

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

    {

        cin>>x;

        v.push_back(x);

        m[x]++;

    }

    long long int ans=0;

    map<long long int,long long int>::iterator it;

    for(it=m.begin();it!=m.end();it++)

    {

        if(it->second>it->first)

        {

            ans+=(it->second)-(it->first);

        }

        else if(it->second<it->first)

        {

            ans+=it->second;

        }

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

    for(int i=1;i<=100000;i++)

    {

        if(a[i]>i){

            ans+=(a[i]-i);

        }

        else if(a[i]<i)

        ans+=a[i];

    }

    printf("%d\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.436296609958403x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int n,x;

    vector<long long int>v;

    map<long long int,long long int>m;

    cin>>n;

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

    {

        cin>>x;

        v.push_back(x);

        m[x]++;

    }

    long long int ans=0;

    map<long long int,long long int>::iterator it;

    for(it=m.begin();it!=m.end();it++)

    {

        if(it->second>it->first)

        {

            ans+=(it->second)-(it->first);

        }

        else if(it->second<it->first)

        {

            ans+=it->second;

        }

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



	for (int i = 1; i < MAX_N; i++)

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4667524624781705x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int n,x;

    vector<long long int>v;

    map<long long int,long long int>m;

    cin>>n;

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

    {

        cin>>x;

        v.push_back(x);

        m[x]++;

    }

    long long int ans=0;

    map<long long int,long long int>::iterator it;

    for(it=m.begin();it!=m.end();it++)

    {

        if(it->second>it->first)

        {

            ans+=(it->second)-(it->first);

        }

        else if(it->second<it->first)

        {

            ans+=it->second;

        }

    }

    cout<<ans<<endl;

    return 0;

}