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