#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int val;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> val;
    a.push_back(val);
  }
  sort(a.begin(), a.end());
  int day = 0;
  int nDay = day + 1;
  for (int i = 0; i < n; i++) {
    if (a[i] >= nDay) {
      a[i] = 0;
      day++;
      nDay = day + 1;
    }
  }
  cout << day;
  return 0;
}
