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

using namespace std;

inline int read()

{

    int r,s=0,c;

    for(;!isdigit(c=getchar());s=c);

    for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);

    return s^45?r:-r;

}

const int N=110000;

int n;

int a[N];

map<int,int> mp;

int ans;

int main()

{

    n=read();

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

        a[i]=read(),mp[a[i]]++;

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

        if(a[i]!=mp[a[i]])

        {

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

        		ans+=mp[a[i]]-a[i],mp[a[i]]=a[i];

        	else

        		ans+=mp[a[i]],mp[a[i]]=0;

		}

    printf("%d\n",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.465144338601447x):
#include<algorithm>

#include<iostream>

using namespace std;

int main()

{

	int i,j,k,ans=0,n;

	cin>>n;

	int a[n];

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

		cin>>a[i];

	sort(a,a+n);

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

	{

		k=1;

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

		{

			if(a[i]==a[j])

				k++;

			else

				break;

		}

		if(k>a[i])

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

		if(k<a[i])

			ans=ans+k;

		//cout<<k<<endl;

	}	

	cout<<ans<<endl;

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

using namespace std;

inline int read()

{

	int x=0,f=1;

	char c=getchar();

	while((c<'0'||c>'9')&&c!='-')c=getchar();

	if(c=='-')f=-1,c=getchar();

	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();

	return f*x;

}

int n,a[100001],t;

int main(){

	n=read();

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

	{

		int x=read();

		if(x>n)t++;

		else a[x]++;

	}

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

	{

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

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

	}

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

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

using namespace std;

int main(){map<int,int>HIM;vector<int>v;int n,ans,i,MC;cin>>n;for(i=1;i<=n;i++){cin>>MC;if(HIM[MC]==0)v.push_back(MC);HIM[MC]++;}for(i=0;i<v.size();i++) {if(HIM[v[i]]>=v[i])ans+=HIM[v[i]]-v[i]; else ans+=HIM[v[i]];}cout<<ans<<endl;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):
// luogu-judger-enable-o2

#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.4619445965889633x):
#include<iostream>

#include<fstream>

#include<algorithm>

#include<cstdio>

#include<cstring>

#include<string>

#include<cmath>



using namespace std;

long long n,h,he;

int a[100000+10];

int main()

{

	cin>>n;

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

	{

		cin>>a[i];

	}

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

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

	{

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

		{

			if(h<a[i-1])

			{

				he+=h;

			}

			else

			{

				he+=h-a[i-1];

			}

			h=1;

		}

		else

		h++;

	}

	cout<<he<<endl;

	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.465855154876425x):
#include<iostream>

using namespace std;

const int N=100001;

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

int main()

{

    cin>>n;

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

    {

        cin>>x;

        if(x>n) ans++;

        else a[x]++; 

    }

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

    {

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

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

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

    }

    cout<<ans<<endl;

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

using namespace std;



map<int,int> m;

vector<int> v;

int n,ans,x;

int main()

{

    cin>>n;

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

	{

        cin>>x;

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

        m[x]++;

    }

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

using namespace std;

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

int main()

{

    cin>>n;

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

    {

        cin>>x;

        if(x>n) ans++;

        else a[x]++;

    }

    for(int i=1;i<=n;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;

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

using namespace std;

int main(){

  int n;

  cin >> n;

  int a;

  int i;

  int numbers[100001] = {};

  int wa = 0;

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

    a = 0;

    cin >> a;

    if(a>100000) wa++;

    else{

      numbers[a]++;

    }

  }

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

    if(numbers[i]<i) wa+=numbers[i];

    else wa+=numbers[i]-i;

  }

  cout << wa;



  

}

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

using namespace std;

int main(){

    int n;

    cin >> n;

    long a[n];

    int ans = 0;

    vector<int>num(n+1,0);

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

        cin >> a[i];

        if(a[i]<=n)num[a[i]]++;

        else ans++;

    }



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

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

        else ans += num[i];

    }

    cout << ans << endl;

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

#include<map>



using namespace std;



map<int, int> mp;



int n, cnt;



int main(void) {

	map<int, int> ::iterator i;

    int t;

    scanf("%d", &n);

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

        scanf("%d", &t);

        mp[t]++;

    }



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

    	int a = (*i).first;

    	int b = (*i).second;

        if(b>=a) cnt += (b-a);

        else cnt += b;

	}

    printf("%d", cnt);



    return 0;

}

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

#include<algorithm>

using namespace std;

int n, a[100010];

int main(void) {

    int i, ncnt, cnt=0;

    scanf("%d", &n);

    for(i=0; i<n; i++) scanf("%d", a+i);

    sort(a, a+n);

    ncnt = 1;

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

        if(a[i]==a[i-1]) ncnt++;

        else {

            cnt += (ncnt>=a[i-1] ? ncnt-a[i-1] : ncnt);

            ncnt = 1;

        }

    }

    if(ncnt==1) {

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

    }

    else {

        cnt += (ncnt>=a[i-1] ? ncnt-a[i-1] : ncnt);

    }



    printf("%d", cnt);



    return 0;

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

#include<map>

using namespace std;



map<int,int> d;



int b[100010],bl=0,ans;



int main(){

	int a,n; cin>>n;

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

		cin>>a; int ok=1;

		if(d[a]==0) b[bl++]=a,d[a]++;

		else d[a]++;

	}

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

		if(d[b[i]]>b[i]) ans+=d[b[i]]-b[i];

		else if(d[b[i]]<b[i]) ans+=d[b[i]];

	}

	cout<<ans<<endl;

	return 0;

} 

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

#include<algorithm>

using namespace std;

int inp[100000];

int main()

{

	int n,ans=0;

	scanf("%d",&n);

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

	sort(inp,inp+n);

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

	{

		cnt=1;

		while(inp[i]==inp[i+1])

		{

			cnt++;

			i++;

		}

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

		else ans+=cnt;

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

int n,ans,s;

map<int,int> m;

vector<int> v;

int main()

{

	cin>>n;

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

		cin>>s;

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

		m[s]++;

	}

	for(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<<endl;

	return 0;

}

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

#include<algorithm>

using namespace std;

int inp[100000];

int main()

{

	int n,ans=0;

	scanf("%d",&n);

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

	sort(inp,inp+n);

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

	{

		cnt=1;

		while(inp[i]==inp[i+1])

		{

			cnt++;

			i++;

		}

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

		else ans+=cnt;

	}

	printf("%d",ans);

	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.245491138955066x):
#include<cstdio>

#include<algorithm>

using namespace std;

int inp[100000];

int main()

{

	int n,ans=0;

	scanf("%d",&n);

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

	sort(inp,inp+n);

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

	{

		cnt=1;

		while(inp[i]==inp[i+1])

		{

			cnt++;

			i++;

		}

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

		else ans+=cnt;

	}

	printf("%d",ans);

	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.246341881268002x):
#include<cstdio>

#include<algorithm>

using namespace std;

int inp[100000];

int main()

{

	int n,ans=0;

	scanf("%d",&n);

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

	sort(inp,inp+n);

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

	{

		cnt=1;

		while(inp[i]==inp[i+1])

		{

			cnt++;

			i++;

		}

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

		else ans+=cnt;

	}

	printf("%d",ans);

	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.246341881268002x):
#include<cstdio>

#include<algorithm>

using namespace std;

int inp[100000];

int main()

{

	int n,ans=0;

	scanf("%d",&n);

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

	sort(inp,inp+n);

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

	{

		cnt=1;

		while(inp[i]==inp[i+1])

		{

			cnt++;

			i++;

		}

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

		else ans+=cnt;

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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


#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<<endl;



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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

using namespace std;

map<int,int> a;

vector<int> b;

int main()

{

  int i,n,sum=0,k;

  cin>>n;

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

  {

    cin>>k;

    if(a[k]==0) 

	  b.push_back(k);

    a[k]++;

  }

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

    if(a[b[i]]>=b[i]) 

	  sum+=a[b[i]]-b[i]; 

	else 

	  sum+=a[b[i]];

  cout<<sum;

  return 0;

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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

using namespace std;

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

int main()

{

    cin>>n;

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

        cin>>x;

        if(x>n) ans++;

        else a[x]++;

    }

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

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

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

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

    }

    cout<<ans<<"\n";

    return 0;

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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

#define _inline __inline__ __attribute__((always_inline))

using namespace std;

_inline void read(int &x){

	int res=0,f=1;

	char c=getchar();

	if(c=='-') f=-1;

	while(c>'9'||c<'0') c=getchar();

	while(c>='0'&&c<='9'){

		res=res*10+c-'0';

		c=getchar();

	}

	x=res*f;

}

inline void print(int x){

    if(x<0) putchar('-'),x=-x;

    if(x>9) print(x/10);

    putchar(x%10+'0');

}

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

int main(){

    read(n);

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

        read(x);

        if(x>n) ans++;

        else a[x]++;

    }

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

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

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

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

    }

    print(ans),puts("");

    exit(0);

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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8067808200061404x):
#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<bits/stdc++.h>

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

using namespace std;

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

int main()

{

    cin>>n;

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

    {

        cin>>x;

        if(x>n) y++;

        else a[x]++;

    }

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

    {

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

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

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

    }

    cout<<y;

    return 0;

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

using namespace std;

int main()

{

	long long n,a[100010]={0},t=0,s;

	cin>>n;

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

		cin>>a[i];

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

	{

		if(a[i]!=0)

		{

		    s=0;

		    if(a[i]<=n)

			{

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

				{

					if(a[j]!=0&&a[j]==a[i]&&j!=i)

					{

						a[j]=0;

						s++;

					}

				}

				s++;

				if(s!=a[i])

				{

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

					else t+=s;

				}

			}

			else t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8123393891953075x):
#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),++m[a];

    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 <cstdio>

#include <cmath>

#include <algorithm>

#include <numeric>

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

#define repr(i, m, n) for(int i = m;i >= n;i--)

#define SORT(v, n) sort(v, v+n);

#define INF 999999999

using namespace std;



int main(){

    int n; cin >> n;

    int rem = 0;

    int temp;

    int a[100001] = {0};

    rep(i, 1, n+1){

        cin >> temp;

        if(temp > 100000) rem += 1;

        else a[temp] += 1;

    }

//    cout << "a[0], a[1] =" << a[0] << " " << a[1] << endl;

    rep(i, 1, 100001){

        if(a[i] == 0) ;

        else if(a[i] < i) rem += a[i];

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

    }



    cout << rem << endl;



    return 0;

}


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

using namespace std;



int main(){

    int n;

    cin >> n;

    vector<int> v(n+1);

    int ans = 0;

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

        int a;

        cin >> a;

        if(a > n) ans++;

        else v[a]++;

    }

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

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

        else ans += v[i];

    }

    cout << ans << endl;

    return 0;

}