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