#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int sol = 0;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  while (!v.empty()) {
    if (sol + 1 <= v.back()) {
      sol++;
    }
    v.erase(v.end() - 1);
  }
  cout << sol;
  return 0;
}
