#include <bits/stdc++.h>
using namespace std;
set<int> m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  vector<int> a;
  int day = 0;
  cin >> n;
  for (int i = 0, t; i < n; i++) {
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] > day) {
      day++;
    }
  }
  cout << day;
  return 0;
}
