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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

V<LL>v;

map<LL,LL>u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    cin>>n;

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

    {

        cin>>o;

        u[o]++;

    }

    k=0;

    for(MLL it=u.B; it!=u.E; it++)

    {

        if(it->SE>it->FI)

        {

            k+=((it->SE)-(it->FI));

        }

        else if(it->SE<it->FI)

        {

            k+=it->SE;

        }

    }

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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

V<LL>v;

map<LL,LL>u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    cin>>n;

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

    {

        cin>>o;

        u[o]++;

    }

    k=0;

    for(MLL it=u.B; it!=u.E; it++)

    {

        if(it->SE>it->FI)

        {

            k+=((it->SE)-(it->FI));

        }

        else if(it->SE<it->FI)

        {

            k+=it->SE;

        }

    }

    cout<<k<<endl;

    return 0;

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

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

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

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

V<LL>v;

map<LL,LL>u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    cin>>n;

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

    {

        cin>>o;

        u[o]++;

    }

    k=0;

    for(MLL it=u.B; it!=u.E; it++)

    {

        if(it->SE>it->FI)

        {

            k+=((it->SE)-(it->FI));

        }

        else if(it->SE<it->FI)

        {

            k+=it->SE;

        }

    }

    cout<<k<<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.4597102541153855x):
/*

        Author: Prokash

                CSE48, JU



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int ara[2005];

int main()

{

    FAST;

    int n,in,ans=0;

    cin>>n;

    vector<int>v(n);

    map<int,int>mp;

    map<int,int>::iterator it;

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

    {

        cin>>v[i];

    }

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

    {

        mp[v[i]]++;

    }

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

    {

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

        {

            ans+=(it->second);

        }

        else

        {

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

        }

    }

    cout<<ans<<endl;

    return 0;

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



using namespace std;



int a[100005];



int in()

{

    int a;

    scanf("%d",&a);

    return a;

}



int main()

{

    int n=in(),ans=0;

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

    {

        int aa=in();

        if(aa>100000)

            ans++;

        else

            a[aa]++;

    }

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

    {

        if(a[i]>i){

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

        }

        else if(a[i]<i)

        ans+=a[i];

    }

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

}


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

        Author: Prokash

                CSE48, JU



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int ara[2005];

int main()

{

    FAST;

    int n,in,ans=0;

    cin>>n;

    vector<int>v(n);

    map<int,int>mp;

    map<int,int>::iterator it;

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

    {

        cin>>v[i];

    }

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

    {

        mp[v[i]]++;

    }

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

    {

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

        {

            ans+=(it->second);

        }

        else

        {

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

        }

    }

    cout<<ans<<endl;

    return 0;

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

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

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

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

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

        Author: Prokash

                CSE48, JU



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int ara[2005];

int main()

{

    FAST;

    int n,in,ans=0;

    cin>>n;

    vector<int>v(n);

    map<int,int>mp;

    map<int,int>::iterator it;

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

    {

        cin>>v[i];

    }

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

    {

        mp[v[i]]++;

    }

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

    {

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

        {

            ans+=(it->second);

        }

        else

        {

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

        }

    }

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

using namespace std;

 

int main(){

	int n; cin >> n;

	map<int, int> M;

	int num;

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

		cin >> num;

		M[num]++;

	}

	auto it = M.begin();

	int cont = 0;

	for(; it != M.end(); it++){

		if((*it).first < (*it).second)

			cont += (*it).second - (*it).first;

		else if ((*it).first > (*it).second)

			cont += (*it).second;

	}

	cout << cont;

	

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

using namespace std;

 

int main(){

	int n; cin >> n;

	map<int, int> M;

	int num;

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

		cin >> num;

		M[num]++;

	}

	auto it = M.begin();

	int cont = 0;

	for(; it != M.end(); it++){

		if((*it).first < (*it).second)

			cont += (*it).second - (*it).first;

		else if ((*it).first > (*it).second)

			cont += (*it).second;

	}

	cout << cont;

	

	return 0;

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

#include <iostream>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5;

int n, ans;

int Arr[MAX_N];

int cnt[MAX_N];



int main() {

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

	cin >> n;

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

		cin >> Arr[i];

		if (n < Arr[i]) {

			i--;

			n--;

			ans++;

		}

	}



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

		cnt[Arr[i]]++;



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

		if (cnt[i] < i)

			ans += cnt[i];

		else

			ans += (cnt[i] - i);



	cout << ans << "\n";

	return 0;

}

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

using namespace std;

 

int main(){

	int n; cin >> n;

	map<int, int> M;

	int num;

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

		cin >> num;

		M[num]++;

	}

	auto it = M.begin();

	int cont = 0;

	for(; it != M.end(); it++){

		if((*it).first < (*it).second)

			cont += (*it).second - (*it).first;

		else if ((*it).first > (*it).second)

			cont += (*it).second;

	}

	cout << cont;

	

	return 0;

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

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	

	int N;

	cin >> N;



	map<int, int> A;



	rep(i, N) {

		int a;

		cin >> a;

		A[a]++;

	}



	int kotae = 0;

	for (auto itr: A) {

		while (itr.second != 0 && itr.second != itr.first) {

			itr.second--;

			kotae++;

		}

	}

	co(kotae);



	Would you please return 0;

}

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

#include<cstdio>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int A[100001];

int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	int kotae = 0;

	rep(i, N) {

		int a = getint();

		if (a <= 100000) A[a]++;

		else kotae++;

	}

	rep1(i, 100000) {

		if (A[i] >= i) kotae += A[i] - i;

		else kotae += A[i];

	}

	printf("%d", kotae);



	Would you please return 0;

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



#define rep(i, N) for (ll i = 0; i < N; i++)

#define rep1(i, N) for (ll i = 1; i <= N; i++)

#define MOD (int)1e9+7;



using ll = long long;

using namespace std;



int main() {

    int N;

    cin >> N;

    int cnt[(int)1e5+3] = {0};

    int ans = 0;



    rep(i, N) {

        int a;

        cin >> a;

        if(a > N) ans++;

        else cnt[a]++;

    }

    

    rep1(i, N) {

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

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

    }



    cout << ans << "\n";

    return 0;

}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)

#define rep(i, N) FOR(i, 0, N)

using namespace std;



typedef long long ll;

typedef pair<int,int> P;

typedef vector<int> vi;

typedef vector<ll> vl;

const ll MOD = round(1e9+7);



int main() {

    int N; cin >> N;

    vi A(N); rep(i,N) cin >> A[i];

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

    A.emplace_back(-1);

    int ans = 0, tmp = 0, cnt = 0;

    rep(i,N+1){

        if(A[i] != tmp){

            ans += (cnt >= tmp?cnt - tmp:cnt);

            tmp = A[i];

            cnt = 1;

        }else{

            cnt++;

        }

    }



    cout << ans << endl;

    return 0;

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

using namespace std;



int main(){

  int n;

  cin >> n;

  int a[n];

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

  int ans=0;

  int count[100001];

  for(int i=0;i<100001;i++) count[i]=0;

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

    if(a[i]>100000){

      ans++;

    }

    else{

      count[a[i]]++;

    }

  }

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

    if(count[i]>=i){

      ans+=count[i]-i;

    }

    else{

      ans+=count[i];

    }

  }

  cout << ans << endl;

}

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <string>

#include <queue>

#include <stack>

#include <set>

#include <map>

#include <iomanip>

#include <utility>

#include <tuple>

#include <functional>

#include <bitset>

#include <cassert>

#include <complex>

#include <stdio.h>

#include <time.h>

#include <numeric>

#include <random>

#include <unordered_map>

#include <unordered_set>

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

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

#define pb push_back

#pragma GCC optimize("O3")

#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<ll, ll> P;

typedef complex<ld> com;

constexpr int inf = 1000000010;

constexpr ll INF = 1000000000000000010;

constexpr ld eps = 1e-12;

constexpr ld pi = 3.141592653589793238;

template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }

template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }





signed main() {

	cin.tie(0);

	ios::sync_with_stdio(false);

	cout << fixed << setprecision(20);



	int n;

	cin >> n;

	vector<int> a(n), cnt(n + 1);

	int ans = 0;

	rep(i, n) {

		cin >> a[i];

		if (a[i] > n) ans++;

		else cnt[a[i]]++;

	}

	rep(i, n + 1) {

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

		else ans += cnt[i] - i;

	}

	cout << ans << '\n';

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



using namespace std;

map<int,int> m;

vector<int> v;

int main()

{

    int n,ans;

    cin>>n;

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

    {

        int x;

        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<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.790006843680656x):


#include <bits/stdc++.h>

using namespace std;

map<int,int>k;

int main()

{

     int n,x,a[100001],ans,ansx=0;

     cin>>n;

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

     {

     	cin>>a[i];

     	k[a[i]]++;

	 }

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

	 ans=unique(a+1,a+n+1)-a-1;

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

	 {

	 	if(k[a[i]]<a[i]) ansx+=k[a[i]];

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

	 }

	 cout<<ansx<<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.807073853556872x):
#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;

}