#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0, i = 0, k = 1;
  cin >> n;
  int arr[n];
  for (; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  for (i = 0; i < n; ++i) {
    if (arr[i] >= k) {
      cnt++;
      arr[i] = 0;
    } else
      continue;
    k++;
  }
  cout << cnt;
  return 0;
}
