#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int day, pos, last = 0;
  for (day = 1; day <= n; ++day) {
    pos = lower_bound(a + last, a + n, day) - a;
    last = pos + 1;
    if (pos == n) break;
  }
  cout << day - 1 << '\n';
  return 0;
}
