#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &s) {
  T t = 1;
  char k = getchar();
  s = 0;
  for (; k < '0' || k > '9'; k = getchar())
    if (k == '-') t = -1;
  for (; k >= '0' && k <= '9'; k = getchar())
    s = (s << 1) + (s << 3) + (k ^ 48);
  s *= t;
}
const int maxn = 2e5 + 5;
const int maxm = 10 + 5;
const int INF = 0x3f3f3f3f;
int n, ans, a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1, j = 1; i <= n; i++) {
    if (a[i] >= j) ans++, j++;
  }
  cout << ans;
  return 0;
}
