stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

#include <sstream>

#include <fstream>

#include <string>

#include <vector>

#include <deque>

#include <queue>

#include <stack>

#include <set>

#include <map>

#include <algorithm>

#include <functional>

#include <utility>

#include <bitset>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstdio>

#include <string.h>

using namespace std;



const int MAXN=100000+10;



map<int,int> mp;

set<int> s;



int a[MAXN];



int main(){

	int n;

	cin>>n;

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

		cin>>a[i];

		mp[a[i]]++;

	}

	int cnt=0;

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

		if(s.find(a[i])!=s.end())continue;

		else if(s.find(a[i])==s.end()){	

			s.insert(a[i]);

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

				cnt+=mp[a[i]];

			}

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

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

			}

		}

	}

	cout<<cnt<<endl;

	return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;

long long n,a[100005],ans;

vector <long long> v;

int main()

{

	cin>>n;

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	/*v.push_back(a[0]);

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

	{

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

			v.push_back(a[i]);

	}*/

	int cur=1;

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

	{

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

		{

			cur++;

		}

		else

		{

			if(cur<a[i-1])

				ans+=cur;

			cur=1;

		}

		if(cur>a[i])

		{

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

			cur=a[i];

		}

	}

	if(cur<a[n-1])

		ans+=cur;

	cout<<ans<<"\n";

	return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

for:

Hussien , Ayman , Emad

Abanob , George , Genawy

Ka8eem , Mosta7il , Stawro



ICPC DREAM

*/

#ifdef _MSC_VER

#define _CRT_SECURE_NO_WARNINGS

#endif

#include<bits/stdc++.h>

#include<unordered_map>

using namespace std;

#define ll long long

#define ld long double

#define ull unsigned ll 

#define endl '\n'

#define mk make_pair

const double PI = acos(-1.0);

void fast_in_out() {

	std::ios_base::sync_with_stdio(NULL);

	cin.tie(NULL); cout.tie(NULL);



}

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

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

const ld eps = 1e-9;

const int mod = 998244353;

const int N = 2e5 + 10, M = 318;

int main() {

	fast_in_out();

	//cout << fixed << setprecision(6);

	// kolo ray7 , ya 5raby

	int n; cin >> n;

	map<int, int>mp;

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

		int x; cin >> x;

		mp[x]++;

	}

	int ans = 0;

	for (auto e : mp) {

		if (e.second == e.first)

			continue;

		if (e.second > e.first)

			ans += (e.second - e.first);

		if (e.second < e.first)

			ans += e.second;

	}

	cout << ans << endl;

	return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;



int main()

{

   long long n,a[100000],i,d=1,kq=0;

   cin>>n;

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

   {

   		cin>>a[i];

  	}

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

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

    {

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

    	{

    		d++;

		}

		else

		{

			if (d>a[i-1])

			{

				kq+=d-a[i-1];

			}

			else if (d<a[i-1])

			{

				kq+=d;

			}

			d=1;

		}

	}

	cout<<kq;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

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

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

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

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

int cnt[100100];

int ans;



int solve(){

    cin >> n;

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

        cin >> x;

        if(x > n) ans++;

        else cnt[x]++;

    }

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

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

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

    }

    return ans;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;

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

#define ll long long

#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

double const EPS = 1e-12, PI = acos(-1);

const int N = 2e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;

const ll inf = 1e18;



map<ll, ll> freq;



int main() {

  fastIO;

#ifdef LOCAL

  freopen("input.in", "rt", stdin);

#endif

  int n, a;

  cin >> n;

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

    cin >> a;

    freq[a]++;

  }

  ll total = 0;

  for(auto it: freq) {

    if(it.second < it.first)

      total += it.second;

    else if(it.second > it.first)

      total += it.second - it.first;

  }

  cout << total;

  return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;

int main()

{



    long long a,b,c,d,i,sum=0;

    map<long long,long long>mp;

    map<long long,long long>:: iterator it;

    cin>>a;

    while(a--)

    {

        cin>>b;

        mp[b]++;





    }

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

    //cout<<it->first<<" "<<it->second<<endl;

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

    {

        d=it->first;

        if(mp[d]<d)

            sum=sum+mp[d];

        else

            sum=sum+abs(mp[d]-d);

    }



    cout<<sum<<endl;









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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;

int main()

{

    int n,i;

    map <int, int> mp;

    map <int, int>::iterator it;

    cin>>n;

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

    {

        int x;

        cin>>x;

        mp[x]++;

    }

    int sum = 0;

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

    {

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

            sum += it->second;

        else

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

    }



    cout<<sum<<endl;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;



#define      ll     long long int



int main()

{

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

    cin >> n;

    map<int, int> mp;

    map<int, int>::iterator it;

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

        cin >> j;

        mp[j]++;

    }

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

        j = (*it).first;

        k = (*it).second;

        if (j == k) continue;

        else if (j > k) {

            s += k;

        }

        else {

            s += (k - j);

        }

    }

    cout << s << '\n';

    return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

//  main.cpp

//  [Problem B]

//

//  Created by Anson Thai on 11/4/20.

//  Copyright © 2020 Anson Thai. All rights reserved.

//



#include <iostream>

#include <map>

#include <iterator>

#include <algorithm>



int main(int argc, const char * argv[]) {

    

    int n;

    

    std::cin >> n;

    

    int array [n];

    

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

           std::cin >> array[i];

    }

    

    

    int sum = 0;



    std::map<int, int> my_map;

    

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

        

        my_map[array[i]] = 0;

    }



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

        

        my_map[array[i]] += 1;

    }

    

    

    for(auto& x : my_map) {

        if (x.first > x.second) {

            sum += x.second;

        } else if (x.first < x.second) {

            sum += x.second - x.first;

        }

    }

    







    std::cout << sum << std::endl;

   

    return 0;

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

using namespace std;



const int MAXN = 1e5 + 10;

int cnt[MAXN], n, ans;



int main() {

	cin >> n;

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

		int a;

		cin >> a;

		if (a > 1e5)

			ans++;

		else

			cnt[a]++;

	}

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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += cnt[i] - i;

	cout << ans;

}

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

using namespace std;

class Seq {

	private:

		// data

		map<int, int> mem;

		int removeCount;

	public:

		Seq() {

			removeCount = 0;

			mem.clear();

		}

		void add(int x) {

			if(mem[x] < x)

				mem[x] += 1;

			else

				removeCount++;

		}

		void sync() {

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

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

					removeCount += it->second;

					it->second = 0;

				}

			}

		}

		int countRemoved() {

			return removeCount;

		}

};

int main()

{

	// fasten

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	Seq db;

	int N;

	cin >> N;

	while(N--)

	{

		int x;

		cin >> x;

		db.add(x); // add x

	}

	db.sync(); // sync

	cout << db.countRemoved() << "\n";

	return 0;

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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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

using namespace std;



map<int, int> cnt;



int main()

{



    int n, x;



    scanf("%d", &n);



    int res = 0;



    while(n--){



        scanf("%d", &x);

        cnt[x]++;

    }



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



        int occ = it->second;



        int key = it->first;



        if(occ>key) res += (occ-key);

        else if(occ<key) res += occ;



    }



    cout<<res<<endl;







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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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

using namespace std;

map<int,int> mp,flag;



int main()

{

    int n;

    cin>>n;

    int a[n+2],ans=0;

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

    {

        cin>>a[i];

        mp[a[i]]++;

    }

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

    {

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

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

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

        flag[a[i]]=1;

    }

    cout<<ans<<endl;

    return 0;

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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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

using namespace std;







map<int, int>mp;

int ara[100009];

int main()

{

	int n;

	scanf("%d",&n);



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

	{

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

		mp[ara[i]]++;

	}





	int tot=0;

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

	{

        int x=ara[i];



		if(mp[x]>=x)

        tot+= mp[x]-x;

        else

			tot+=mp[x];



        mp[x]=x;



	}





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



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

using namespace std;







map<int, int>mp;

int ara[100009];

int main()

{

	int n;

	scanf("%d",&n);



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

	{

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

		mp[ara[i]]++;

	}





	int tot=0;

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

	{

        int x=ara[i];



		if(mp[x]>=x)

        tot+= mp[x]-x;

        else

			tot+=mp[x];



        mp[x]=x;



	}





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



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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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

using namespace std;



int cnt[100009];



int main()

{

    //cout<<cnt[1000000000]<<endl;



    int n;

    scanf("%d",&n);

    int a[100009];

    int uniq[100009];



    int i=0;

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

    {

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

        //cnt[a[i]]++;

    }



    sort(a,a+n);

    int j =0;

    cnt[j]=1;

    uniq[j] = a[0];

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

    {

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

        {

            j++;

            cnt[j]=1;

            uniq[j]=a[i];

        }

        else cnt[j]++;

    }

    int ans =0;

    i=0;

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

    {

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

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

    }

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

    //main();



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

using namespace std;



int cnt[100009];



int main()

{

    //cout<<cnt[1000000000]<<endl;



    int n;

    scanf("%d",&n);

    int a[100009];

    int uniq[100009];



    int i=0;

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

    {

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

        //cnt[a[i]]++;

    }



    sort(a,a+n);

    int j =0;

    cnt[j]=1;

    uniq[j] = a[0];

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

    {

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

        {

            j++;

            cnt[j]=1;

            uniq[j]=a[i];

        }

        else cnt[j]++;

    }

    int ans =0;

    i=0;

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

    {

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

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

    }

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

    //main();



    return 0;

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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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



using namespace std;



int main() {



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



    int n;

    cin >> n;



    map < long, long > cnt;



    long a[n];

    vector < long > lst;



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



        cin >> a[i];

        if(cnt[a[i]]==0) lst.push_back(a[i]);

        cnt[a[i]]++;

    }

    long lagbe = 0;

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

        int v = lst[i];

        if(v!=cnt[v]) {

            if(cnt[v]>v) {

                lagbe += cnt[v]-v;

            }

            else lagbe += cnt[v];

        }

    }



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



using namespace std;



int main() {



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



    int n;

    cin >> n;



    map < long, long > cnt;



    long a[n];

    vector < long > lst;



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



        cin >> a[i];

        if(cnt[a[i]]==0) lst.push_back(a[i]);

        cnt[a[i]]++;

    }

    long lagbe = 0;

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

        int v = lst[i];

        if(v!=cnt[v]) {

            if(cnt[v]>v) {

                lagbe += cnt[v]-v;

            }

            else lagbe += cnt[v];

        }

    }



    cout << lagbe << endl;





    return 0;

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

#include <cmath>

#include <algorithm>



int c[100001];



int main() {

  long long int n;

  long long int count = 0;

  std::cin >> n;

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

    c[i] = 0;

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

    int x = 0;

    std::cin >> x;

    if (x >= 100001) {

      count++;

      continue;

    }   

    c[x]++;

  }

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

    count += (c[i] < i) ? c[i]: c[i] - i;

  }

  std::cout << count << std::endl;

  return 0;

}


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

#include<algorithm>

using namespace std;



int a[100005],b[100005],c[100005];



int main(){

	int ans=0;

	int n;

	scanf("%d",&n);

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

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

	}

	int m=0;

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

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

		if(a[i]!=c[m]){

			c[++m]=a[i];

			b[m]=1;

		}

		else{

			b[m]++;

		}

	}

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

		if(b[i]>=c[i]){

			ans+=b[i]-c[i];

		}

		else ans+=b[i];

	}

	printf("%d",ans);

	return 0;

}