#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, MAXN = 1e6, INF = 2 * 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for (int &x : v) {
    cin >> x;
  }
  sort(v.begin(), v.end());
  int counter = 1, ans = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i] >= counter) ++counter, ++ans;
  }
  cout << ans << endl;
  return 0;
}
