#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int p = 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p <= a[i]) {
      ans++;
      p++;
    }
  }
  cout << ans << endl;
}
