stablegradients/pie-gem5-pairs huggingface dataset:
// 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<iostream>

using namespace std;

int n,a[100001],x,ans;//数组如果开到10亿，就超空间了

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>n) ans++;//大于n的x删除，计数器加一

		else a[x]++;//不大于n的x的桶加一，计量x出现的次数

	}

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

	{

		if(a[i]==0) continue;//桶为0，表示i从未出现

		if(a[i]<i) ans+=a[i];//i不超过装它的桶，全部删除

		else if(a[i]>i) ans+=a[i]-i;//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.8097928479031082x):
#include<bits/stdc++.h>

using namespace std;

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

int main()

{

	cin>>n;

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

	{

		cin>>x;

		if(x>n)

		{

			ans++;

			continue;

		} 

		MAX=max(MAX,x);

		a[x]++;

	}

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

	{

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

		if(a[i]<i)

		{

			ans+=a[i];

			continue;

		} 

		ans+=a[i]-i;

	}

	cout<<ans<<endl;

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

using namespace std;

int n,a[1000001],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)

        {

            if(a[i]<i)

            {

                ans+=a[i];

            }

            else

            {

             ans+=a[i]-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[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;

    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.8102706017601264x):
#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=ans+a[i];

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

	}

	cout<<ans<<endl;

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

#include<cstdio>

#include<algorithm>

#define N 100000+5

using namespace std;

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

int main()

{

	scanf("%d",&n);

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

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

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

	{

		f++;

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

		{

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

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

			f = 0;

		}

	}

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

using namespace std;

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

int main()

{

    scanf("%d", &n);

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

        scanf("%d", &x), (x > n) ? ans++ : a[x]++;

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

        if (a[i] != 0)

            if (a[i] < i)

                ans += a[i];

            else if (a[i] > i)

                ans += a[i] - i;

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

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

using namespace std;

const int Maxn=1e5+10;

int n,a[Maxn],ans;

map <int,int> mp;

int main(){

	cin>>n;

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

		cin>>a[i];

		mp[a[i]]++;

	}

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

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

			ans+=it->second;

		else

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

	}

	cout<<ans;



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

using namespace std;

#define int long long

signed main() {

    #ifdef HOME

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

    #else

    ios_base::sync_with_stdio(0); cin.tie(0);

    #endif



    map <int, int> d;

    int n;

    cin >>n;

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

        int x;

        cin >> x;

        ++d[x];

    }   

    int ans = 0;

    for (auto e : d) {

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

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

    }   

    cout << ans << '\n';

}
// 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.353691684821129x):
#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;

}
// 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.9973417293220488x):
#include <iostream>

#include <string>

#include <cstring>

#include <cstdio>

#include <cstdlib>

#include <vector>

#include <cmath>

#include <algorithm>

#include <map>

#include <sstream>

#include <queue>

#include <deque>

#include <set>

#include <stack>

#include <functional>

#include <utility>

#include <stdio.h>

#define ll long long

#define MP make_pair

#define PII pair<int, int>

#define PLL pair<ll, ll>

#define PLI pair<ll, int>

#define PIL pair<int, ll>

#define F first

#define S second

#define SHN 1e9

#define LSHN 1e18

using namespace std;

int n;

map<int, int> mp;

int res;

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++)

	{

		int x=it->first,y=it->second;

		if (x==y) continue;

		if (x<y) res+=y-x;

		else res+=y;

	}

	cout <<res;

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

#include <string>

#include <cstring>

#include <cstdio>

#include <cstdlib>

#include <vector>

#include <cmath>

#include <algorithm>

#include <map>

#include <sstream>

#include <queue>

#include <deque>

#include <set>

#include <stack>

#include <functional>

#include <utility>

#include <stdio.h>

#define ll long long

#define MP make_pair

#define PII pair<int, int>

#define PLL pair<ll, ll>

#define PLI pair<ll, int>

#define PIL pair<int, ll>

#define F first

#define S second

#define SHN 1e9

#define LSHN 1e18

using namespace std;

int n;

map<int, int> mp;

int res;

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++)

	{

		int x=it->first,y=it->second;

		if (x==y) continue;

		if (x<y) res+=y-x;

		else res+=y;

	}

	cout <<res;

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

#include<sstream>

#include<fstream>

#include<string>

#include<vector>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<functional>

#include<algorithm>

#include<bitset>

#include<utility>

#include<cmath>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<ctime>

using namespace std;

#define ll long long

map<ll,ll>m;

int ans=0;

int n;

int main()

{

	ios::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

	cin>>n;

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

	{

		ll a;

		cin>>a;

		m[a]++;

	}

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

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

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

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

			ans+=it->second;

	cout<<ans;

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

#include<sstream>

#include<fstream>

#include<string>

#include<vector>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<functional>

#include<algorithm>

#include<bitset>

#include<utility>

#include<cmath>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<ctime>

using namespace std;

#define ll long long

map<ll,ll>m;

int ans=0;

int n;

int main()

{

	ios::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

	cin>>n;

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

	{

		ll a;

		cin>>a;

		m[a]++;

	}

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

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

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

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

			ans+=it->second;

	cout<<ans;

	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: 1.970341333265769x):
//#pragma GCC optimize(2)

//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º

//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£

//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£

// Happy TLE and WA every day!

// by: zxb

#include<bits/stdc++.h>

#define mp              make_pair

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

#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define BINF            0x7fffffff

#define INF             0x3f3f3f3f

#define LINF            4557430888798830399

#define pb              push_back

#define F               first

#define S               second

#define Time            clock()/CLOCKS_PER_SEC

#define read            ZXBs_fast_input

#define write           ZXBs_fast_output

//#define usingFiles

using namespace std;



typedef unsigned int ui;

typedef pair<int, int> pii;

typedef long long ll;



inline bool read(int& x){

	x = 0;

	int c;

	int sign = 1;

	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;

	x = c ^ '0';

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

	x *= sign;

	return 1;

}



inline bool write(int x){

	if(x >= 10) write(x / 10);

	putchar(x % 10 + '0');

	return 1;

}



const int rp = 666666;

const bool debug = 1;

const bool I_good_vegetable_a = 1;



int n;

int a[100100];

map<int, int> cnt;

map<int, bool> done;



signed main(){

	ios::sync_with_stdio(false);

	#ifdef usingFiles

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

		freopen("output.txt", "w", stdout);

	#endif

	cin >> n;

	rep(i, n){

		cin >> a[i];

		cnt[a[i]]++;

	}

	int ans = 0;

	rep(i, n){

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

		done[a[i]] = 1;

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

		else ans += (cnt[a[i]]);

	}

	cout << ans << 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.4555318285242491x):
//#pragma GCC optimize(2)

//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º

//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£

//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£

// Happy TLE and WA every day!

// by: zxb

#include<bits/stdc++.h>

#define mp              make_pair

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

#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define BINF            0x7fffffff

#define INF             0x3f3f3f3f

#define LINF            4557430888798830399

#define pb              push_back

#define F               first

#define S               second

#define Time            clock()/CLOCKS_PER_SEC

#define read            ZXBs_fast_input

#define write           ZXBs_fast_output

//#define usingFiles

using namespace std;



typedef unsigned int ui;

typedef pair<int, int> pii;

typedef long long ll;



inline bool read(int& x){

	x = 0;

	int c;

	int sign = 1;

	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;

	x = c ^ '0';

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

	x *= sign;

	return 1;

}



inline bool write(int x){

	if(x >= 10) write(x / 10);

	putchar(x % 10 + '0');

	return 1;

}



const int rp = 666666;

const bool debug = 1;

const bool I_good_vegetable_a = 1;



int n;

int a[100100];

map<int, int> cnt;

map<int, bool> done;



signed main(){

	ios::sync_with_stdio(false);

	#ifdef usingFiles

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

		freopen("output.txt", "w", stdout);

	#endif

	cin >> n;

	rep(i, n){

		cin >> a[i];

		cnt[a[i]]++;

	}

	int ans = 0;

	rep(i, n){

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

		done[a[i]] = 1;

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

		else ans += (cnt[a[i]]);

	}

	cout << ans << endl;

	return 0;

}