#include <bits/stdc++.h>
const char dl = '\n';
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const double PI = 3.141592653589793238463;
const long double pi = 4 * atan(1.0);
using namespace std;
void debug() { cout << endl; }
template <typename H, typename... T>
void debug(H p, T... t) {
  std::cout << p << " ";
  debug(t...);
}
string second, t;
long long ans;
int n, m, k;
stack<char> STACK;
deque<char> DEQUE;
queue<char> QUEUE;
int main() {
  fflush(stdin);
  cout << fixed, cout.precision(18);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;
  cin >> n;
  int a[n];
  multiset<int> seta;
  for (i = 0; i < n; ++i) cin >> a[i], seta.insert(a[i]);
  for (i = 1; i <= n; ++i) {
    auto it = seta.lower_bound(i);
    if (it == seta.end()) return cout << i - 1, 0;
    seta.erase(it);
  }
  cout << n;
}
