#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, _c = 0, _t = 1;
  cin >> n;
  vector<long long> dfx(n);
  for (int i = 0; i < n; i++) cin >> dfx[i];
  sort(begin(dfx), end(dfx));
  for (auto x : dfx)
    if (x >= _t) _t++;
  cout << --_t;
}
