#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
int num[maxn], n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &num[i]);
  sort(num, num + n);
  int where = lower_bound(num, num + n, 1) - num;
  int ans = 0;
  while (where != n) {
    ans++;
    where = lower_bound(num + where + 1, num + n, ans + 1) - num;
  }
  printf("%d\n", ans);
}
