#include <bits/stdc++.h>
using namespace std;
const long long int N = 200010;
const long long mod = 1000000007;
const long long inf = 1000000000000000000;
const long double pi = 3.14159265358979323846264338;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  long long int ans = 0, cnt = 1;
  for (long long int i = 0; i < n; i++) {
    if (a[i] >= cnt) ans++, cnt++;
  }
  cout << ans;
  return 0;
}
