#include <bits/stdc++.h>
using namespace std;
void executor(long long int test_case) {
  long long int n, k;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long int counter = 0, days = 1;
  for (long long int i = 0; i < n; ++i) {
    if (a[i] >= days) {
      counter++;
      days++;
    }
  }
  cout << counter << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  for (long long int i = 1; i <= t; i++) executor(i);
}
