#include <bits/stdc++.h>
using namespace std;
multiset<long long> contest;
int N;
int main() {
  scanf("%d", &N);
  long long v;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &v);
    contest.insert(v);
  }
  long long total = 0;
  while (!contest.empty()) {
    long long first = *contest.begin();
    contest.erase(contest.begin());
    if (first >= total + 1) {
      ++total;
    }
  }
  printf("%lld\n", total);
}
