#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  multiset<int> contests;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    contests.insert(t);
  }
  int cnt = 0, cur = 1;
  auto it = contests.begin();
  while (n--) {
    int t = *it;
    if (cur <= t) {
      cnt++;
      cur++;
    }
    it++;
  }
  cout << cnt << "\n";
  return 0;
}
