#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, turn = 0, flag = 0, count = 0;
  cin >> n;
  long long int a[n];
  long long int b[200000] = {0};
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i] - 1] = b[a[i] - 1] + 1;
  }
  for (long long int j = 0; j < 200000; j++) {
    if (b[j] == 0) {
      turn = turn + 1;
    } else if (b[j] > 0) {
      count = count + 1;
      b[j] = b[j] - 1;
      if (b[j] >= turn) {
        count = count + turn;
        turn = 0;
      } else {
        turn = turn - b[j];
        count = count + b[j];
      }
    }
  }
  cout << count;
  return 0;
}
