#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[n];
  for (int i = 0; i < n; i++) cin >> ara[i];
  sort(ara, ara + n);
  int cnt = 0, num = 0;
  for (int i = 0; i < n; i++) {
    if (ara[i] > num) {
      cnt++;
      num++;
    }
  }
  cout << cnt << "\n";
  return 0;
}
