#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int c;
  int arr[200001];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int j = 1;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] >= j) {
      sum++;
      j++;
    }
  }
  cout << sum << endl;
}
