stablegradients/pie-gem5-pairs huggingface dataset:
// 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.4540697837253462x):
#include <bits/stdc++.h>

using namespace std;



#define DB	double

#define lf	else if

#define	I64	long long

#define Rd()	(rand() << 15 | rand())

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

#define Rep(i,a,b)	for(int i=a;i>=b;i--)

	

#define fi	first

#define se	second

#define MK	make_pair

#define PA	pair<int, int>



#define CH	(ch=getchar())

int		IN()	{

		int x= 0, f= 0, ch;

		for (; CH < '0' || ch > '9';)	f= (ch == '-');

		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';

		return	f ? -x : x;

}



#define n	200005



int		N, K, M, B[n];



map<int, int>	A;



bool	Cmp(int a, int b)	{

		return	A[a] < A[b];

}



int		main()	{

		N= IN();

		For(i, 1, N)	{

			int x= IN();

			A[x]++;

			

			if	(A[x] == 1)	B[++ M]= x;

		}

		

		int ans= 0;

		For(i, 1, M)	if	(A[B[i]] >= B[i])	ans+= A[B[i]] - B[i];

			else	ans+= A[B[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.4205378712198757x):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc087.contest.atcoder.jp/tasks/arc087_a>

問題文============================================================

 長さ N の正整数の列 a=(a1,a2,…,aN) が与えられます。

 あなたの目標は、a のうちいくつかの要素を取り除き、a を 良い数列 にすることです。

 

 ここで、数列 b が 良い数列 であるとは、次の条件が成り立つことです。

 

 b の各要素 x について、b に値 x はちょうど x 個含まれる。

 例えば、(3,3,3), (4,2,4,1,4,2,4), () (空の数列) は良い数列です。

 一方、(3,3,3,3), (2,4,1,4,2) は良い数列ではありません。

 

 a を良い数列にするために取り除くべき要素の個数の最小値を求めてください。

=================================================================



解説=============================================================



 連想配列である数値が何個存在するのかを保存しておき、順番に見ていけば良い

 

================================================================

*/

int main(void) {

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

    ll N; cin >> N;

    map<ll,ll> mp;

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

        ll A; cin >> A;

        mp[A]++;

    }

    ll ans = 0;

    for(auto p:mp){

        if(p.first < p.second) ans += p.second - p.first;

        else if(p.first > p.second) ans += p.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.4285638026221945x):
#include <bits/stdc++.h>

using namespace std;



#define int long long



const int N = 1e5 + 10;

int n, ans, ar[N];

vector <int> vec;

map <int, int> cnt;



int32_t main() {

	ios::sync_with_stdio(0);

	cin.tie(0);

	

	cin >> n;

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

		cin >> ar[i];

		cnt[ar[i]]++;

		vec.push_back(ar[i]);

	}

	sort(vec.begin(), vec.end());

	vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end())));

	

	for (int i : vec)

		if (cnt[i] > i)

			ans += cnt[i] - i;

		else if (cnt[i] < i)

			ans += cnt[i];

	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.4478553510598098x):
#include <bits/stdc++.h>

using namespace std;

vector<int> quq;

int main(){

	long long n,a,i,pos,ans=0,sz;

	cin>>n;

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

	{

		cin>>a;

		quq.push_back(a);

	}

	sort(quq.begin(),quq.end());

	for(i=0;i<quq.size();)

	{

		pos=upper_bound(quq.begin(),quq.end(),quq[i])-quq.begin();

		sz=pos-i;

		if(sz<quq[i])

		{

			ans+=sz;

		}

		else

		{

			ans+=sz-quq[i];

		}

		i=pos;

	}

	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.4165309942841615x):
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

using namespace std;

#define endl "\n"

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

#define allr(v)	     ((v).rbegin()), ((v).rend())

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

#define clr(v, d)        memset(v, d, sizeof(v))

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

typedef long long ll;

int dx[]{ 0,0,1,-1,-1,1,1 ,-1 };

int dy[]{ -1,1,0,0 ,1,1,-1,-1 };

void file() {

#ifndef ONLINE_JUDGE

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

#endif

}

//////

const int N = 2e3 + 10, mod = 1e9+7;

///////////

template<class Int>

Int gcd(Int a, Int b)

{

	return (b == 0 ? a : gcd(b, a%b));

}

template<class Int>

Int lcm(Int a, Int b)

{

	return a / gcd(a, b)*b;

}

int main()

{

	cout << setprecision(8) << fixed;

	IO

	//	file();

	///////////

	int n;

	cin >> n;

	map<int, int>mp;

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

		int x;

		cin >> x;

		mp[x]++;

	}

	int cnt = 0;

	for (auto v : mp) {

		if (v.second > v.first)

			cnt += v.second - v.first;

		else if (v.second < v.first)

			cnt += v.second;

	}

	cout << cnt << 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.4490563699528833x):
#include<bits/stdc++.h>

#define  ll  long long int

#define  sz  200010



using namespace std;



map<ll,ll>mp;



int main()

{



    ll s=0,i,j,k,p,d,n,a,b;



    cin>>n;



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

    {

        cin>>a;

        mp[a]++;

    }



    map<ll,ll>::iterator it;



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

    {

        a=it->first;

        b=it->second;



        if(b<a)s+=b;

        else if(b>a)

        {

            s+=(b-a);

        }

    }



    cout<<s<<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.4206564296104789x):
#include <bits/stdc++.h>

 

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 

#define af(i,a,b) for( ll i = a; i >= b ; i--)

#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )

#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)

#define ones(x) (ll) __builtin_popcount(x);1

#define fs first

#define sc second

#define pb push_back

#define po pop_back

#define mp make_pair	

#define sz(a) (ll) a.size()

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

#define sor(a) sort( a.begin(), a.end() )

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

#define yes cout<<"YES\n"

#define no cout<<"NO\n"

using namespace std;

typedef long long ll;

typedef long double ld;	

typedef pair<ll,ll> ii ;

typedef vector<ll>  vi ;

typedef vector<ii> vii ;

 

const ll MAX = 10000000;

const ll inf = 5e18-1;





int main() {

	fastio;

	ll n,i;

    cin>>n;

    ll a;

    map<ll,ll> f;

    f(i,0,n)

    {

        cin>>a;

        f[a]++;

    }

    ll ans=0;

    for (auto e: f)

    {

        if (e.fs<e.sc)

            ans+=e.sc-e.fs;

        else if (e.fs>e.sc)

            ans+=e.sc;

    }

    cout<<ans<<endl;

	return 0;

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

using namespace std;

int xx[100005];

int main()

{

    int n,v,c=0;

    cin>>n;

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

    {

        cin>>v;

        if(v>100000)c++;

        else xx[v]++;

    }

    vector<int>vc,vc1;

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

    {

        if(xx[i]!=0)

        {

            if(xx[i]<i)c+=xx[i];

            else if(xx[i]>i)c+=xx[i]-i;

        }

    }

      cout<<c<<endl;



    return 0;

}


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

 

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 

#define af(i,a,b) for( ll i = a; i >= b ; i--)

#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )

#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)

#define ones(x) (ll) __builtin_popcount(x);1

#define fs first

#define sc second

#define pb push_back

#define po pop_back

#define mp make_pair	

#define sz(a) (ll) a.size()

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

#define sor(a) sort( a.begin(), a.end() )

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

#define yes cout<<"YES\n"

#define no cout<<"NO\n"

using namespace std;

typedef long long ll;

typedef long double ld;	

typedef pair<ll,ll> ii ;

typedef vector<ll>  vi ;

typedef vector<ii> vii ;

 

const ll MAX = 10000000;

const ll inf = 5e18-1;





int main() {

	fastio;

	ll n,i;

    cin>>n;

    ll a;

    map<ll,ll> f;

    f(i,0,n)

    {

        cin>>a;

        f[a]++;

    }

    ll ans=0;

    for (auto e: f)

    {

        if (e.fs<e.sc)

            ans+=e.sc-e.fs;

        else if (e.fs>e.sc)

            ans+=e.sc;

    }

    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.4366539070431958x):
#include<bits/stdc++.h>

using namespace std;



int main(){

	map<int,int> mp;

	map<int,int>::iterator it;

	int n,a,sum=0;

	cin>>n;

	while(n--){

		cin>>a;

		if(mp.count(a)) mp[a]++;

		else mp[a]=1;

	}

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

		pair<int,int> cur = *it;

		if(cur.first!=cur.second){

			if(cur.first>cur.second) sum+=cur.second;

			else sum+=cur.second-cur.first;

		}

	}

	cout<<sum<<endl;

	return 0;

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

using namespace std;

int xx[100005];

int main()

{

    int n,v,c=0;

    cin>>n;

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

    {

        cin>>v;

        if(v>100000)c++;

        else xx[v]++;

    }

    vector<int>vc,vc1;

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

    {

        if(xx[i]!=0)

        {

            if(xx[i]<i)c+=xx[i];

            else if(xx[i]>i)c+=xx[i]-i;

        }

    }

      cout<<c<<endl;



    return 0;

}


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

using namespace std;



int main(){

	map<int,int> mp;

	map<int,int>::iterator it;

	int n,a,sum=0;

	cin>>n;

	while(n--){

		cin>>a;

		if(mp.count(a)) mp[a]++;

		else mp[a]=1;

	}

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

		pair<int,int> cur = *it;

		if(cur.first!=cur.second){

			if(cur.first>cur.second) sum+=cur.second;

			else sum+=cur.second-cur.first;

		}

	}

	cout<<sum<<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.4462907949044812x):
#include <iostream>

#include <map>

#include <vector>



#include <algorithm>



using namespace std;



int main()

{

    map<int,int> map_int_int; 

    int test;

    cin >> test;

    

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

    {

    	int bil;

    	cin>> bil;

    	if(!map_int_int[bil]) map_int_int[bil] = 1;

    	else map_int_int[bil]++;

	}

	

	int remove=0;

	for (map<int,int>::iterator it = map_int_int.begin() ; it != map_int_int.end() ; ++it) // mengiterasi semua isi dari map_int_string

    {

        pair<int,int> cur = *it;

//		cout << cur.first;

//		cout << "\n";

//		cout << cur.second;

		if(cur.second>cur.first) remove += cur.second - cur.first;

		else if (cur.second < cur.first) remove += cur.second;

    }

    

    cout << remove << "\n";

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

using namespace std;

int xx[100005];

int main()

{

    int n,v,c=0;

    cin>>n;

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

    {

        cin>>v;

        if(v>100000)c++;

        else xx[v]++;

    }

    vector<int>vc,vc1;

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

    {

        if(xx[i]!=0)

        {

            if(xx[i]<i)c+=xx[i];

            else if(xx[i]>i)c+=xx[i]-i;

        }

    }

      cout<<c<<endl;



    return 0;

}


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

#include <map>

#include <vector>



#include <algorithm>



using namespace std;



int main()

{

    map<int,int> map_int_int; 

    int test;

    cin >> test;

    

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

    {

    	int bil;

    	cin>> bil;

    	if(!map_int_int[bil]) map_int_int[bil] = 1;

    	else map_int_int[bil]++;

	}

	

	int remove=0;

	for (map<int,int>::iterator it = map_int_int.begin() ; it != map_int_int.end() ; ++it) // mengiterasi semua isi dari map_int_string

    {

        pair<int,int> cur = *it;

//		cout << cur.first;

//		cout << "\n";

//		cout << cur.second;

		if(cur.second>cur.first) remove += cur.second - cur.first;

		else if (cur.second < cur.first) remove += cur.second;

    }

    

    cout << remove << "\n";

}
// 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.4616505110243887x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

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

    int n;

    cin>>n;

    ll a[n];

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

    sort(a,a+n);

    int c=1,ans=0;

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

        if(a[i]==a[i+1]) c++;

        else

        {

            if(a[i]!=c)

            {



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

                else ans+=c;

            }

            c=1;

        }

    cout<<ans<<endl;

//return main();

}
// 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.4711970163716668x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    int arr[n+1],i;

    for(i=0; i<n; i++) scanf("%d",&arr[i]);

    sort(arr, arr+n);

    arr[n]=arr[n-1]+1;

    int ans=0,c=1;

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

    {

        if(arr[i]!=arr[i+1])

        {

            if(arr[i]<c) ans+=fabs(c-arr[i]);

            else if(arr[i]>c) ans+=c;

            //printf("%d %d\n",arr[i],c);

            c=1;

        }

        else c++;

    }

    //if(c>1) ans+=fabs(arr[i]-c);

    printf("%d\n",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.4457616687452604x):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    map<int, int>Map;

    int n, x, ans=0;

    cin>>n;

    while(n--) scanf("%d", &x), Map[x]++;

    for(auto it : Map){

        if(it.first!=it.second){

            if(it.second<it.first) ans += it.second;

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

        }

    }

    cout<<ans<<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.458644653676702x):
#include<bits/stdc++.h>

using namespace std;

const int maxN = 1e5 + 13;

int n, a[maxN], ans;

map<int, bool> mark;

map<int, int> cnt;

vector<int> vec;

int main () {

    cin >> n;

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

	cin >> a[i];

	if (!mark[a[i]]) {

	    mark[a[i]] = 1;

	    vec.push_back(a[i]);

	}

	cnt[a[i]]++;

    }



    for (auto it : vec) {

	if (cnt[it] < it)

	    ans += cnt[it];

	else

	    ans += cnt[it] - it;

    }

    cout << ans << 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.9392688065504602x):
#include<bits/stdc++.h>

using namespace std;

const int maxN = 1e5 + 13;

int n, a[maxN], ans;

map<int, bool> mark;

map<int, int> cnt;

vector<int> vec;

int main () {

    cin >> n;

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

	cin >> a[i];

	if (!mark[a[i]]) {

	    mark[a[i]] = 1;

	    vec.push_back(a[i]);

	}

	cnt[a[i]]++;

    }



    for (auto it : vec) {

	if (cnt[it] < it)

	    ans += cnt[it];

	else

	    ans += cnt[it] - it;

    }

    cout << ans << endl;

}