#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  vector<long> v;
  cin >> n;
  long x;
  for (long i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  long index = 0;
  bool cont = true;
  long day = 1;
  while (cont == true && index < n) {
    if (v[index] >= day) {
      day++;
      index++;
    } else {
      while (v[index] < day && index < n) {
        index++;
      }
    }
  }
  cout << day - 1;
}
