#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
long long mod = 1000000007;
int main() {
  long long i, j, k = 0, n, m = 0, a[300001], b[300001], t = 0, ans = 0, i1 = 0,
                  i2, h, p1, p2 = 0, q, l, f, c[2], mi;
  char c1, c2, d[1001][1001];
  string s;
  double j1;
  string e, dz;
  std::vector<pair<long long, long long>> vect;
  vector<long long> v;
  map<string, long long> m1;
  map<string, long long>::iterator itr;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  j = 1;
  for (i = 0; i < n; i++) {
    if (a[i] >= j) {
      t++;
      j++;
    }
  }
  cout << t;
}
