#include <bits/stdc++.h>
int A[200005];
int cmp(const void* a, const void* b) { return *(int*)a - *(int*)b; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  qsort(A, n, sizeof(int), cmp);
  int pos = 1;
  for (int i = 0; i < n; i++) {
    if (A[i] >= pos) {
      pos++;
    }
  }
  printf("%d\n", pos - 1);
  return 0;
}
