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