#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const long double pi = 3.1415926535897932384626433832795;
template <typename T>
void debug(vector<T> x) {
  for (auto e : x) {
    cout << e << " ";
  }
  cout << "\n";
}
void solve2() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long i = 0;
  long long ans = 0;
  long long needed = 1;
  while (i < n) {
    if (v[i] >= needed) {
      ans++;
      needed++;
    }
    i++;
  }
  cout << ans;
  cout << "\n";
  return;
  ;
}
signed main() {
  long long t = 1;
  while (t--) {
    solve2();
  }
  return 0;
}
