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