#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vl = vector<ll>;
int ceil(vi& contest, int x) {
  int start = 0, end = (int)contest.size() - 1;
  int ans = -1;
  while (start <= end) {
    int mid = start + (end - start) / 2;
    if (contest[mid] >= x) {
      ans = mid;
      end = mid - 1;
    } else
      start = mid + 1;
  }
  return ans;
}
long solve(vi& contest, int N) {
  long ans = 0;
  int prblms = 1;
  while (prblms <= N) {
    int d = ceil(contest, prblms);
    if (d == -1) break;
    ans++;
    prblms++;
    contest.erase(contest.begin() + d);
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  vi contest(N);
  for (int i = 0; i < N; i++) cin >> contest[i];
  sort(contest.begin(), contest.end());
  long ans = 1;
  for (int i = 0; i < N; i++) {
    if (contest[i] >= ans) {
      ans++;
    }
  }
  cout << ans - 1 << "\n";
  return 0;
}
