#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 100;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long n, arr[maxn], ans = 0, dis = 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + 1 + n);
  while (dis <= n) {
    if (arr[dis] > ans) ans++;
    dis++;
  }
  cout << ans << endl;
  return 0;
}
