#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MM = 2e5 + 20;
int a[MM];
int main() {
  int i, j, k, cnt = 0;
  int n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  for (j = 1, i = 1; j <= n && i <= n; i++) {
    while (j <= n && a[j] < i) j++;
    if (a[j] >= i) {
      cnt++;
      j++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
