#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int res;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  res = 1;
  for (int i = 1; i <= n; ++i)
    if (a[i] >= res) res++;
  cout << res - 1;
}
