#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long *arr = new long long[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long count = 0;
  int j = 0;
  for (int i = 0; i < n && j < n; i++, j++) {
    if (arr[j] >= i + 1) {
      count++;
    } else {
      while (arr[j] < i + 1 && j < n) j++;
      if (j == n) break;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
