#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    v.push_back(num);
  }
  sort(v.begin(), v.end());
  int maxx = 1;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] >= maxx) {
      maxx++;
    }
  }
  cout << maxx - 1 << endl;
  return 0;
}
