#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using namespace chrono;
int64_t ceil_div(int64_t a, int64_t b) { return (a + b - 1) / b; }
void solve() {
  int64_t n;
  cin >> n;
  vector<int64_t> arr(n);
  for (auto& i : arr) cin >> i;
  sort(arr.begin(), arr.end());
  int64_t count = 0;
  int64_t temp = 0;
  for (int64_t i = 0; i < n; ++i) {
    if (arr[i] > temp) {
      count++;
      temp++;
    }
  }
  cout << count << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start1 = high_resolution_clock::now();
  int64_t t = 1;
  while (t--) {
    solve();
  }
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
  return 0;
}
