#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int rd() {
  int sum = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = (sum << 1) + (sum << 3) + ch - '0';
    ch = getchar();
  }
  return sum * flag;
}
long long RD() {
  long long sum = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = (sum << 1) + (sum << 3) + ch - '0';
    ch = getchar();
  }
  return sum * flag;
}
int arr[200010];
int main() {
  int n = rd();
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    arr[i] = rd();
  }
  sort(arr + 1, arr + 1 + n);
  int now = 1;
  for (int i = 1; i <= n; i++) {
    if (arr[i] >= now) {
      now++;
    }
  }
  cout << now - 1 << endl;
  return 0;
}
