#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long fp(long long a, long long b) {
  if (b == 0) return 1;
  long long x = fp(a, b / 2);
  x = (x * x) % mod;
  if (b & 1) x = (x * a) % mod;
  return x;
}
auto random_add = [] {
  char *p = new char;
  delete p;
  return uint64_t(p);
};
const uint64_t SEED =
    chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);
const long long N = 2e5 + 5;
void solve() {
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  long long last = 0;
  for (long long i = 1; i <= n; i++) {
    if (a[i] >= 1 + last) last++;
  }
  cout << last << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
}
