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

using namespace std;



int main()

{

    long int n,ar[100005],check[100005]={0},i,c=0;

    cin>>n;

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

    {

        cin>>ar[i];

        if(ar[i]>100000)

        {

            c++;

        }

        else if(ar[i]<=100000)

        {

            check[ar[i]]++;

        }

    }



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

    {

        if(check[i]>i)

        {

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

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }

    cout<<c<<endl;

    return 0;

}


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

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,m,a,b,c;

    cin>>n;

    map<ll,ll>mp;

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

    {

        cin>>k;

        mp[k]++;

    }

    map<ll,ll>::iterator it;

    c=0;

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

    {

        k=it->first;

        l=it->second;

        if(k!=l)

        {

            if(k>l)

            {

                c+=abs(l-0);

            }

            else if(k<l)

            {

                c+=abs(k-l);

            }

        }

    }

    cout<<c<<endl;

    return 0;



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

using namespace std;



const int N = 1e5 + 100;



int n, num, ans, cnt[N];



int main() {

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

	cin >> n;

	while(n--) {

		cin >> num;

		if(num >= N)

			ans++;

		else

			cnt[num]++;

	}

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

		if(cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

	return 0;

}

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

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,m,a,b,c;

    cin>>n;

    map<ll,ll>mp;

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

    {

        cin>>k;

        mp[k]++;

    }

    map<ll,ll>::iterator it;

    c=0;

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

    {

        k=it->first;

        l=it->second;

        if(k!=l)

        {

            if(k>l)

            {

                c+=abs(l-0);

            }

            else if(k<l)

            {

                c+=abs(k-l);

            }

        }

    }

    cout<<c<<endl;

    return 0;



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

using namespace std;



int main()

{

    long int n,ar[100005],check[100005]={0},i,c=0;

    cin>>n;

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

    {

        cin>>ar[i];

        if(ar[i]>100000)

        {

            c++;

        }

        else if(ar[i]<=100000)

        {

            check[ar[i]]++;

        }

    }



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

    {

        if(check[i]>i)

        {

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

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }

    cout<<c<<endl;

    return 0;

}


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

    using namespace std;

    int main(){

    	int n;

    	scanf("%d",&n);

    	int a[n];

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

    		scanf("%d",a+i);

    	}

    	sort(a,a+n);

    	map<int,int> mp,mp2;

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

    		mp[a[i]]++;

    	}

    	int res=0;

    	for(int i=n-1;i>=0;--i){

    		if(mp2[a[i]]>0)continue;

    		if(mp[a[i]] > a[i]){

    			res += mp[a[i]]-a[i];

    			mp2[a[i]]++;

    		}

    		else if(mp[a[i]]<a[i]){

    			res += mp[a[i]];

    			mp2[a[i]]++;

    		}

    	}

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

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

using namespace std;



const int N = 1e5 + 100;



int n, num, ans, cnt[N];



int main() {

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

	cin >> n;

	while(n--) {

		cin >> num;

		if(num >= N)

			ans++;

		else

			cnt[num]++;

	}

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

		if(cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

	return 0;

}

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

    using namespace std;

    int main(){

    	int n;

    	scanf("%d",&n);

    	int a[n];

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

    		scanf("%d",a+i);

    	}

    	sort(a,a+n);

    	map<int,int> mp,mp2;

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

    		mp[a[i]]++;

    	}

    	int res=0;

    	for(int i=n-1;i>=0;--i){

    		if(mp2[a[i]]>0)continue;

    		if(mp[a[i]] > a[i]){

    			res += mp[a[i]]-a[i];

    			mp2[a[i]]++;

    		}

    		else if(mp[a[i]]<a[i]){

    			res += mp[a[i]];

    			mp2[a[i]]++;

    		}

    	}

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

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

using namespace std;



int main()

{

    long int n,ar[100005],check[100005]={0},i,c=0;

    cin>>n;

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

    {

        cin>>ar[i];

        if(ar[i]>100000)

        {

            c++;

        }

        else if(ar[i]<=100000)

        {

            check[ar[i]]++;

        }

    }



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

    {

        if(check[i]>i)

        {

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

        }

        else if(check[i]<i)

        {

            c = c+check[i];

        }

    }

    cout<<c<<endl;

    return 0;

}


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

#include <bits/stdc++.h>



#define fin(s) freopen( s, "r", stdin );

#define fout(s) freopen( s, "w", stdout );



using namespace std;

int main() 

{

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



	long N;

	cin >> N;

	vector<long> ar;

	long input;

	while(N-- && cin >> input){

		ar.push_back(input);

	}

	map<long,long> m;

	for(vector<long>::iterator t=ar.begin(); t!=ar.end(); t++){

		m[*t]++;

	}

	long c = 0;

	for(auto v : m){

		if(v.second<v.first)

			c+=v.second;

		else

			c+=v.second-v.first;

	}

	cout << c << "\n";





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

using namespace std;



const int N = 1e5 + 100;



int n, num, ans, cnt[N];



int main() {

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

	cin >> n;

	while(n--) {

		cin >> num;

		if(num >= N)

			ans++;

		else

			cnt[num]++;

	}

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

		if(cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

	return 0;

}

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

#include <bits/stdc++.h>



#define fin(s) freopen( s, "r", stdin );

#define fout(s) freopen( s, "w", stdout );



using namespace std;

int main() 

{

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



	long N;

	cin >> N;

	vector<long> ar;

	long input;

	while(N-- && cin >> input){

		ar.push_back(input);

	}

	map<long,long> m;

	for(vector<long>::iterator t=ar.begin(); t!=ar.end(); t++){

		m[*t]++;

	}

	long c = 0;

	for(auto v : m){

		if(v.second<v.first)

			c+=v.second;

		else

			c+=v.second-v.first;

	}

	cout << c << "\n";





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

#include <cstdio>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

int main(){

	ios::sync_with_stdio(false);

	map<int, int> mapNums;

	vector<int> arrNums;

	register int i;

	int n, nCount=0;

	cin >> n;

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

		int x;

		cin >> x;

		if (mapNums[x] == 0)

			arrNums.push_back(x);

		++mapNums[x];

	}

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

		if (mapNums[arrNums[i]] >= arrNums[i])

			nCount += mapNums[arrNums[i]] - arrNums[i]; 

		else 

			nCount += mapNums[arrNums[i]];

	}

	cout << nCount << endl;

endapp:

	//system("pause > nul");

	return 0;

}

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

#include<map>

#define F(a) for(register int (i)(0);(i)<(a);(i)++)

int n,a[100010];

std::map<int,int> m;

signed main()

{

	scanf("%d",&n);int t,now(0),ans(0);

	F(n)

	{

		scanf("%d",&t);

		if(!m[t])

		{

			a[now++]=t;

		}

		m[t]++;

	}

	F(now)

	{

		(ans+=m[a[i]])-=a[i]*(m[a[i]]>=a[i]);

	}

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

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

#include <cstdio>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

int main(){

	ios::sync_with_stdio(false);

	map<int, int> mapNums;

	vector<int> arrNums;

	register int i;

	int n, nCount=0;

	cin >> n;

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

		int x;

		cin >> x;

		if (mapNums[x] == 0)

			arrNums.push_back(x);

		++mapNums[x];

	}

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

		if (mapNums[arrNums[i]] >= arrNums[i])

			nCount += mapNums[arrNums[i]] - arrNums[i]; 

		else 

			nCount += mapNums[arrNums[i]];

	}

	cout << nCount << endl;

endapp:

	//system("pause > nul");

	return 0;

}

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

#include <map>

using namespace std;

int a[100005];

map<int,int>f;

int main()

{

	int i,n,ans=0;

	scanf ("%d",&n);

	for (i=1; i<=n; i++) scanf ("%d",&a[i]),f[a[i]]++;

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

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

		else if (f[a[i]]>a[i]) ans+=(f[a[i]]-a[i]),f[a[i]]=a[i];

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

	return 0;

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

using namespace std;

int n,a[100001],x,ans;

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>100000) ans++;

		else a[x]++;

	}

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

	{

		if(a[i]==0) continue;

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

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

	}

	cout<<ans;

	return 0;

}

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

#include <map>

using namespace std;

int a[100005];

map<int,int>f;

int main()

{

	int i,n,ans=0;

	scanf ("%d",&n);

	for (i=1; i<=n; i++) scanf ("%d",&a[i]),f[a[i]]++;

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

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

		else if (f[a[i]]>a[i]) ans+=(f[a[i]]-a[i]),f[a[i]]=a[i];

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

	return 0;

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

using namespace std;

int n,a[100001],x,ans;

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>100000) ans++;

		else a[x]++;

	}

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

	{

		if(a[i]==0) continue;

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

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

	}

	cout<<ans;

	return 0;

}

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

#include<fstream>

#include<cstdio>

#include<cmath>

#include<string>

#include<cstring>

#include<string.h>

#include<algorithm>

using namespace std;

int n,a[1000010],s,g;

int main()

{

	cin>>n;

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

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

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

	s=1;

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

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

		{

			if(s>a[i-1])g+=(s-a[i-1]);

			if(s<a[i-1])g+=s;

			s=1;

		}

		else s++;	

	if(s>a[n])g+=(s-a[n]);

	if(s<a[n])g+=s;

	cout<<g<<endl;

	return 0;

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

using namespace std;

int n,a[100001],x,ans;

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>100000) ans++;

		else a[x]++;

	}

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

	{

		if(a[i]==0) continue;

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

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

	}

	cout<<ans;

	return 0;

}

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

using namespace std;

int a[100001];

int main()

{

	int n;

	cin>>n;

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

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

	int cnt=0,cn=0;

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

	{

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

		{

			if(cn>=a[i-1]) cnt+=cn-a[i-1];

			else cnt+=cn;

			cn=1;

		}

		else cn++;

	}

	cout<<cnt<<endl;

	return 0;

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

using namespace std;

int n,a[100001],x,ans;

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>100000) ans++;

		else a[x]++;

	}

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

	{

		if(a[i]==0) continue;

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

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

	}

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3958348318647724x):
#include"stdio.h"

#include"iostream"

using namespace std;

int a[100005],n,x,i,ans=0;

int main(){

    scanf("%d",&n);

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

        scanf("%d",&x);

        if(x>n) ans++;

        else a[x]++;

    }

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

        if(a[i]==0) continue;

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

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

    }

    printf("%d",ans);

    return 0;

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

using namespace std;

int n,a[100010],b,ans;

int main()

{

	cin>>n;

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

	{

		cin>>b;

		if(b>100000)

		  ans++;

		else a[b]++;

	}

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

	{

		if(a[i]>=i)

		  ans+=a[i]-i;

		else ans+=a[i];

	}

	cout<<ans;

}

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

using namespace std;



map<int,int> m;

vector<int> v;



int main(){

    int n,ans;

    cin>>n;

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

        int x;

        cin>>x;

        if(m[x]==0) v.push_back(x);

        ++m[x];

    }

    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];

    cout<<ans;

    return 0;

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

using namespace std;

int n,a[100010],b,ans;

int main()

{

	cin>>n;

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

	{

		cin>>b;

		if(b>100000)

		  ans++;

		else a[b]++;

	}

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

	{

		if(a[i]>=i)

		  ans+=a[i]-i;

		else ans+=a[i];

	}

	cout<<ans;

}

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

#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)//宏定义

using namespace std;

int n,a,ans;map<int,int>m;

main()

{

    scanf("%d",&n);

    rpt(n)

	{

		scanf("%d",&a);

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

		else m[a]=1;

	}

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

	{

		pair<int,int>now=*i;

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

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

	}

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

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

#include<iomanip>

#include<cmath>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

#include<set>

#include<map>

#include<queue>

#include<stack>

#include<vector>

#include<cctype>

#define F(a,b,c) for(register int (a)(b);(a)<=(c);(a)++)

using namespace std;

int n;

map<int,int> m;

vector<int> v;

signed main()

{

	scanf("%d",&n);int tmp,ans(0);

	F(i,1,n){scanf("%d",&tmp);if(!m[tmp]){v.push_back(tmp);};m[tmp]++;}

	F(i,0,v.size()){ans+=(m[v[i]]-((m[v[i]]>=v[i])*v[i]));}

	printf("%d",ans);

	return putchar(10),0;

}

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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

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

#include<cmath>

#include<stack>

#include<cstdio>

#include<queue>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

map<int,int>a;

vector<int>q;

int n,ans;

int main(){

	scanf("%d",&n);

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

        int x;

        scanf("%d",&x);

        if(!a[x])q.push_back(x);

        a[x]++;

	}

	int top=q.size();

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

        if(a[q[i]]>=q[i])ans+=a[q[i]]-q[i];

        else ans+=a[q[i]];

	}

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

	return 0;

}


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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

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

using namespace std;

int n,a[100010],b,ans;

int main()

{

	cin>>n;

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

	{

		cin>>b;

		if(b>100000)

		  ans++;

		else a[b]++;

	}

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

	{

		if(a[i]>=i)

		  ans+=a[i]-i;

		else ans+=a[i];

	}

	cout<<ans;

}

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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

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

using namespace std;



map<int,int> m;

vector<int> v;



int main(){

    int n,ans;

    cin>>n;

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

        int x;

        cin>>x;

        if(m[x]==0) v.push_back(x);

        ++m[x];

    }

    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];

    cout<<ans;

    return 0;

}


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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

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

#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)//宏定义

using namespace std;

int n,a,ans;map<int,int>m;

main()

{

    scanf("%d",&n);

    rpt(n)

	{

		scanf("%d",&a);

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

		else m[a]=1;

	}

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

	{

		pair<int,int>now=*i;

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

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

	}

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

}/**/

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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

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

using namespace std;



map<int,int> m;

vector<int> v;



int main(){

    int n,ans;

    cin>>n;

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

        int x;

        cin>>x;

        if(m[x]==0) v.push_back(x);

        ++m[x];

    }

    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];

    cout<<ans;

    return 0;

}

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

#define tin int

#define itn int

#define tni int

#define nit int

#define nti int

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define ll long long

#define inl inline

#define br break

#define con continue

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

#define re register itn

#define fora(x,a,b) for(re x=a;x<=b;++x)

#define forb(x,a,b) for(re x=a;x>=b;--a)

#define infa 0x3f3f3f3f

#define infb 0x7fffffff

#define infc 1061109567

#define infd 0x7f

using namespace std;

#define maxa 100004

#define maxb 10004

#include<cstring>



tni num,x,n[maxa]={0},sum=0;



tin main()

{

	scanf("%d",&num);

	fora(i,1,num)

	{

		scanf("%d",&x);

		if(x>num)

		{

			++sum;

		}

		else

		{

			++n[x];

		}

	}

	//

	fora(i,1,num)

	{

		if(n[i]<i)

		{

			sum+=n[i];

		}

		else if(n[i]>i)

		{

			sum+=n[i]-i;

		}

	}

	//

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

	return 0;

}