#include <bits/stdc++.h>
using namespace std;
bool cmp1(int a, int b) { return a < b; }
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 2];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n, cmp1);
  int t = 1, cnt = 0;
  for (int i = 1; i <= n; i++) {
    while (1) {
      if (a[t] >= i) {
        cnt++;
        t++;
        break;
      } else
        t++;
      if (t == n + 1) {
        break;
      }
    }
    if (t == n + 1) {
      break;
    }
  }
  printf("%d", cnt);
  return 0;
}
