#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  int ans = 0, ind = 0;
  for (int i = 0; i < n; i++) {
    auto x = lower_bound(arr.begin() + ind, arr.end(), (i + 1));
    if (x == arr.end())
      break;
    else {
      ans++;
      ind = x - arr.begin() + 1;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
