#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  deque<int> a(n);
  for (auto& x : a) cin >> x;
  sort(a.begin(), a.end());
  int i;
  for (i = 1; i <= n; ++i) {
    while (!a.empty() && a.front() < i) a.pop_front();
    if (a.empty()) break;
    a.pop_front();
  }
  cout << i - 1 << "\n";
  return 0;
}
