#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int pos = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= pos) pos++;
  }
  cout << --pos << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
