#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, counter = 0, day = 1;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    while (a[i] < day) {
      if (i == n - 1)
        goto go;
      else
        i++;
    }
    counter++;
    day++;
  }
go:
  cout << counter;
}
