#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n;
  scanf("%d", &n);
  int i, j;
  int sum = 0;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (i = 1, j = 1; i <= n;) {
    if (a[i] >= j) {
      sum++;
      i++;
      j++;
    } else {
      i++;
    }
  }
  cout << sum << endl;
  return 0;
}
