#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  vector<int> a;
  int inp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> inp;
    a.push_back(inp);
  }
  sort(a.begin(), a.end());
  int days = 1;
  int next = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= days) {
      days++;
    }
  }
  cout << days - 1;
  return 0;
}
