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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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

#include<sstream>

#include<fstream>

#include<string>

#include<vector>

#include<deque>

#include<queue>

#include<stack>

#include<set>

#include<map>

#include<algorithm>

#include<functional>

#include<utility>

#include<bitset>

#include<cmath>

#include<cstdlib>

#include<ctime>

#include<cstdio>

using namespace std;

map<int,int>mp;

int n,ans;

int main()

{

	cin>>n;

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

	{

		int x;

		cin>>x;

		mp[x]++;

	}

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

	{

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

		{

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

		}

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

		{

			ans+=it->second;

		}

	}

	cout<<ans<<endl;

	return 0;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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

#include<algorithm>

#include<iostream>

#include<iomanip>

#include<cstring>

#include<cstdlib>

#include<utility>

#include<string>

#include<cmath>

#include<cstdio>

#include<vector>

#include<bitset>

#include<ctime>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

using namespace std;

const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ

const int N=100005,M=1000005,mod=1000000007;

const long long llinf=9223372036854775807ll;

//int & long long

int n,a,ans;

map<int,int> mp;

int main(){

	scanf("%d",&n);

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

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

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

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

		{

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

				ans+=it->second;

			else

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

		}

	cout<<ans;

	return 0;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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

using namespace std;

int N;

int A[100100];

map<int,int> M;

int ans;

int main()

{

	cin>>N;

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

		cin>>A[i],

		M[A[i]]++;

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

		if(M[A[i]]>=A[i])

			ans+=M[A[i]]-A[i],

			M[A[i]]=A[i];

		else

			ans+=M[A[i]],

			M[A[i]]=0;

	cout<<ans<<endl;

	return 0;

}
// Slower C++ solution:


/// 28-01-2018

/// MD:NUR ALAM

/// Eastern University of Bangladesh



#include "bits/stdc++.h"



#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define repp(i, a, b) for (int i = (a); i < (b); ++i)

#define fo(i, a, b) for (int i = (a); i <(b); ++i)

#define fors(i, s) for (int i = 0; s[i]; ++i)

#define rs(x) scanf("%s", (x))

#define mp make_pair

#define pb push_back

#define mso(X) memset((X), 0, sizeof((X)))

#define MS1(X) memset((X), -1, sizeof((X)))

#define len(X) strlen(x)

#define nur 100000

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef long double lu;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vpll;

typedef pair<int,int> Pll;

typedef map<string,int>msi;

typedef set<int>se;



template<class t> void _r(t &x) { cin >> x; }

void _r(int &x) { scanf("%d", &x); }

void _r(int64_t &x) { scanf("%lld", &x); }

void _r(double &x) { scanf("%lf", &x); }

void _r(char &x) { scanf(" %c", &x); }

void _r(char *x) { scanf("%s", x); }

void r() {}

template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }

template<class t> void _w(const t &x) { cout << x; }

void _w(const int &x) { printf("%d", x); }

void _w(const int64_t &x) { printf("%lld", x); }

void _w(const double &x) { printf("%.16f", x); }

void _w(const char &x) { putchar(x); }

void _w(const char *x) { printf("%s", x); }

template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}

void w() {}

template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }

template<class t, class... u> void debug(const t &head, const u &... tail) {

#ifdef HOME

#endif

}



///------------------------------------------------------------------------------------------------------------------------------------





int main()

{

    ll n,c=0,check[100005]={0};

    r(n);

    ll ar[n];



    rep(i,n){

        r(ar[i]);



        if(ar[i]>nur)

        {

            c++;

        }

        else if(ar[i]<=nur)

        {

            check[ar[i]]++;

        }

    }



    rep(i,nur){

        if(check[i]>i)

        {

            c = c+(check[i]-i);

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }



    w(c);

}


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

using namespace std;

int N;

int A[100100];

map<int,int> M;

int ans;

int main()

{

	cin>>N;

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

		cin>>A[i],

		M[A[i]]++;

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

		if(M[A[i]]>=A[i])

			ans+=M[A[i]]-A[i],

			M[A[i]]=A[i];

		else

			ans+=M[A[i]],

			M[A[i]]=0;

	cout<<ans<<endl;

	return 0;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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


  //In The Name Of GOD



#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll mod = 998244353;

const ll inf = 2000000000;

const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;

const ll maxn = 100*1000+1;

#define pb push_back

#define pp pop_back

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);



int main(){

  IO;

  int n,a,ans=0;

  cin>>n;

  map<int,int> mp;

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

    cin>>a;

    mp[a]++;

  }

  for(auto p:mp){

    if(p.Y<p.X){

      ans+=p.Y;

    }else{

      ans+=p.Y-p.X;

    }

  }

  cout<<ans;

}
// Slower C++ solution:


/// 28-01-2018

/// MD:NUR ALAM

/// Eastern University of Bangladesh



#include "bits/stdc++.h"



#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define repp(i, a, b) for (int i = (a); i < (b); ++i)

#define fo(i, a, b) for (int i = (a); i <(b); ++i)

#define fors(i, s) for (int i = 0; s[i]; ++i)

#define rs(x) scanf("%s", (x))

#define mp make_pair

#define pb push_back

#define mso(X) memset((X), 0, sizeof((X)))

#define MS1(X) memset((X), -1, sizeof((X)))

#define len(X) strlen(x)

#define nur 100000

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef long double lu;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vpll;

typedef pair<int,int> Pll;

typedef map<string,int>msi;

typedef set<int>se;



template<class t> void _r(t &x) { cin >> x; }

void _r(int &x) { scanf("%d", &x); }

void _r(int64_t &x) { scanf("%lld", &x); }

void _r(double &x) { scanf("%lf", &x); }

void _r(char &x) { scanf(" %c", &x); }

void _r(char *x) { scanf("%s", x); }

void r() {}

template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }

template<class t> void _w(const t &x) { cout << x; }

void _w(const int &x) { printf("%d", x); }

void _w(const int64_t &x) { printf("%lld", x); }

void _w(const double &x) { printf("%.16f", x); }

void _w(const char &x) { putchar(x); }

void _w(const char *x) { printf("%s", x); }

template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}

void w() {}

template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }

template<class t, class... u> void debug(const t &head, const u &... tail) {

#ifdef HOME

#endif

}



///------------------------------------------------------------------------------------------------------------------------------------





int main()

{

    ll n,c=0,check[100005]={0};

    r(n);

    ll ar[n];



    rep(i,n){

        r(ar[i]);



        if(ar[i]>nur)

        {

            c++;

        }

        else if(ar[i]<=nur)

        {

            check[ar[i]]++;

        }

    }



    rep(i,nur){

        if(check[i]>i)

        {

            c = c+(check[i]-i);

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }



    w(c);

}


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


  //In The Name Of GOD



#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll mod = 998244353;

const ll inf = 2000000000;

const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;

const ll maxn = 100*1000+1;

#define pb push_back

#define pp pop_back

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);



int main(){

  IO;

  int n,a,ans=0;

  cin>>n;

  map<int,int> mp;

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

    cin>>a;

    mp[a]++;

  }

  for(auto p:mp){

    if(p.Y<p.X){

      ans+=p.Y;

    }else{

      ans+=p.Y-p.X;

    }

  }

  cout<<ans;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.4446290942198066x):
//https://vjudge.net/contest/331523#problem/D

/*

* Author : MaxSally

*/

/********   All Required Header Files ********/

#include<bits/stdc++.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/

#define SCD(t) scanf("%d",&t)

#define SCLD(t) scanf("%ld",&t)

#define SCLLD(t) scanf("%lld",&t)

#define SCC(t) scanf("%c",&t)

#define SCS(t) scanf("%s",t)

#define SCF(t) scanf("%f",&t)

#define SCLF(t) scanf("%lf",&t)

#define mem(a, b) memset(a, (b), sizeof(a))

#define rep(i, j, k) for (int i = j ; i <= k ; ++i)

#define rrep(i, j, k) for (int i = j; i >= k; --i)

#define all(cont) cont.begin(), cont.end()

#define rall(cont) cont.end(), cont.begin()

#define foreach(i, a) for(auto i: a)

#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define in(A, B, C) assert( B <= A && A <= C)

#define mp make_pair

#define pb push_back

#define inf (int) (1e9 + 7)

#define epsi 1e-9

#define PI 3.1415926535897932384626433832795

#define mod 1000000007

#define read(type) readInt<type>()

#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long int

#define left tuyiuoi

#define right fgjhk

#define ss second

#define ff first

#define debug(a) cout << #a << ": " << a << endl

#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl

#define Flag(n) cout << "here " << n << endl

const double pi=acos(-1.0);

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef vector<vl> vll;

typedef pair<ll, ll> pll;

typedef vector<string> vs;

typedef vector<pii> vii;

typedef vector<pll> vpll;

typedef vector<vi> vvi;

typedef map<int,int> MPII;

typedef set<int> SETI;

typedef multiset<int> MSETI;

typedef long int int32;

typedef unsigned long int uint32;

typedef long long int int64;

typedef unsigned long long int  uint64;



const int N = 100005;

MPII m;



int main(){

    io;

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

    int n; cin >> n;

    rep(i, 1, n){

        int x; cin >> x;

        if(m.find(x) == m.end()){

            m.insert(mp(x, 1));

        }else{

            m[x]++;

        }

    }

    int total = 0;

    foreach(a, m){

        if(a.ff <= a.ss){

            total += a.ss - a.ff;

        }else{

            total += a.ss;

        }

    }

    cout << total;

    return 0;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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



using namespace std;

const int N=5e5+5,mod=1e9+7;

#define ll long long

int cnt[N];

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    int n,ans=0;

    cin>>n;

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

    {

        int x;

        cin>>x;

        if(x>n) ans++;

        else cnt[x]++;

    }

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

    {

        if(cnt[i]>=i)

            ans+=cnt[i]-i;

        else ans+=cnt[i];

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:


/// 28-01-2018

/// MD:NUR ALAM

/// Eastern University of Bangladesh



#include "bits/stdc++.h"



#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define repp(i, a, b) for (int i = (a); i < (b); ++i)

#define fo(i, a, b) for (int i = (a); i <(b); ++i)

#define fors(i, s) for (int i = 0; s[i]; ++i)

#define rs(x) scanf("%s", (x))

#define mp make_pair

#define pb push_back

#define mso(X) memset((X), 0, sizeof((X)))

#define MS1(X) memset((X), -1, sizeof((X)))

#define len(X) strlen(x)

#define nur 100000

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef long double lu;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vpll;

typedef pair<int,int> Pll;

typedef map<string,int>msi;

typedef set<int>se;



template<class t> void _r(t &x) { cin >> x; }

void _r(int &x) { scanf("%d", &x); }

void _r(int64_t &x) { scanf("%lld", &x); }

void _r(double &x) { scanf("%lf", &x); }

void _r(char &x) { scanf(" %c", &x); }

void _r(char *x) { scanf("%s", x); }

void r() {}

template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }

template<class t> void _w(const t &x) { cout << x; }

void _w(const int &x) { printf("%d", x); }

void _w(const int64_t &x) { printf("%lld", x); }

void _w(const double &x) { printf("%.16f", x); }

void _w(const char &x) { putchar(x); }

void _w(const char *x) { printf("%s", x); }

template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}

void w() {}

template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }

template<class t, class... u> void debug(const t &head, const u &... tail) {

#ifdef HOME

#endif

}



///------------------------------------------------------------------------------------------------------------------------------------





int main()

{

    ll n,c=0,check[100005]={0};

    r(n);

    ll ar[n];



    rep(i,n){

        r(ar[i]);



        if(ar[i]>nur)

        {

            c++;

        }

        else if(ar[i]<=nur)

        {

            check[ar[i]]++;

        }

    }



    rep(i,nur){

        if(check[i]>i)

        {

            c = c+(check[i]-i);

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }



    w(c);

}


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



using namespace std;

const int N=5e5+5,mod=1e9+7;

#define ll long long

int cnt[N];

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    int n,ans=0;

    cin>>n;

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

    {

        int x;

        cin>>x;

        if(x>n) ans++;

        else cnt[x]++;

    }

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

    {

        if(cnt[i]>=i)

            ans+=cnt[i]-i;

        else ans+=cnt[i];

    }

    cout<<ans<<endl;

    return 0;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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

#include <stdio.h>

#include <string.h>

#include <algorithm>

#include <math.h>

#include <stdlib.h>

#include <queue>

#include <stack>

#define ll long long

#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

const int maxn=1e5+5;

int a[maxn];

int main()

{

    int n;

    cin>>n;

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

        cin>>a[i];

    sort(a,a+n);

    int ans=1,ans_num=a[0],sum=0;

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

    {

        if(a[i]==ans_num)

            ans++;

        else

        {

            if(ans>=ans_num)

                sum+=ans-ans_num;

            else

                sum+=ans;

            ans_num=a[i];

            ans=1;

        }

    }

    if(ans>=ans_num)

        sum+=ans-ans_num;

    else

        sum+=ans;

    cout<<sum<<endl;

    return 0;

}

/*

4 8



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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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



using namespace std;

int main()

{



  int a,b,d,c,i,j,k,l=0;

 vector<int>v;

map<int,int>m;

cin>>a;

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

{

 cin>>b;

        if(b>100000){l++;}else{

    m[b]++;

if(m[b]==1)v.push_back(b);}

 }

for(i=0;i<v.size();i++)

{

 k=v[i];

 if(k==m[k])

 {

 }

 else if(k>m[k])l+=m[k];

 else if(k<m[k])l+=(m[k]-k);

}

cout<<l<<endl;

}
// Slower C++ solution:


/// 28-01-2018

/// MD:NUR ALAM

/// Eastern University of Bangladesh



#include "bits/stdc++.h"



#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define repp(i, a, b) for (int i = (a); i < (b); ++i)

#define fo(i, a, b) for (int i = (a); i <(b); ++i)

#define fors(i, s) for (int i = 0; s[i]; ++i)

#define rs(x) scanf("%s", (x))

#define mp make_pair

#define pb push_back

#define mso(X) memset((X), 0, sizeof((X)))

#define MS1(X) memset((X), -1, sizeof((X)))

#define len(X) strlen(x)

#define nur 100000

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef long double lu;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vpll;

typedef pair<int,int> Pll;

typedef map<string,int>msi;

typedef set<int>se;



template<class t> void _r(t &x) { cin >> x; }

void _r(int &x) { scanf("%d", &x); }

void _r(int64_t &x) { scanf("%lld", &x); }

void _r(double &x) { scanf("%lf", &x); }

void _r(char &x) { scanf(" %c", &x); }

void _r(char *x) { scanf("%s", x); }

void r() {}

template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }

template<class t> void _w(const t &x) { cout << x; }

void _w(const int &x) { printf("%d", x); }

void _w(const int64_t &x) { printf("%lld", x); }

void _w(const double &x) { printf("%.16f", x); }

void _w(const char &x) { putchar(x); }

void _w(const char *x) { printf("%s", x); }

template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}

void w() {}

template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }

template<class t, class... u> void debug(const t &head, const u &... tail) {

#ifdef HOME

#endif

}



///------------------------------------------------------------------------------------------------------------------------------------





int main()

{

    ll n,c=0,check[100005]={0};

    r(n);

    ll ar[n];



    rep(i,n){

        r(ar[i]);



        if(ar[i]>nur)

        {

            c++;

        }

        else if(ar[i]<=nur)

        {

            check[ar[i]]++;

        }

    }



    rep(i,nur){

        if(check[i]>i)

        {

            c = c+(check[i]-i);

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }



    w(c);

}


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



using namespace std;

int main()

{



  int a,b,d,c,i,j,k,l=0;

 vector<int>v;

map<int,int>m;

cin>>a;

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

{

 cin>>b;

        if(b>100000){l++;}else{

    m[b]++;

if(m[b]==1)v.push_back(b);}

 }

for(i=0;i<v.size();i++)

{

 k=v[i];

 if(k==m[k])

 {

 }

 else if(k>m[k])l+=m[k];

 else if(k<m[k])l+=(m[k]-k);

}

cout<<l<<endl;

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

using namespace std;



int ar[100001];



int main()

{

    int N,temp;

    cin>>N;

    int cnt=0;

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

    {



        cin>>temp;

        if(temp>100000) cnt++;

        else ar[temp]++;

    }



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

    {

        if(ar[i]>=i) cnt+=(ar[i]-i);

        else cnt+=ar[i];

    }

    cout<<cnt<<endl;

}


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

* AUTHOR : Haoyang(Max) Chen

* INSTITUTION : Australian National Unversity

*/



#include <cmath>

#include <iostream>

#include <vector>

#include <cstring>

#include <ctime>

#include <cstdlib>

#include <random>

#include <map>

using namespace std;



#define ll long long



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);



	int l, v, ans = 0;



	cin >> l;



	map<int, int> fm;

	map<int, int>::iterator it;



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

		cin >> v;

		++fm[v];

	}



	for(it = fm.begin(); it != fm.end(); ++it){

		if (it -> first != it -> second){

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

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

			}

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

				ans += it -> second;

			}

		}

	}



	cout << ans << endl;



	return 0;

}