#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int day = 1;
  j = 0;
  int ans = 0;
  while (j < n) {
    if (a[j] >= day) {
      ans++;
      day++;
    }
    j++;
  }
  printf("%d\n", ans);
  return 0;
}
