#include <bits/stdc++.h>
using namespace std;
vector<int> adj[2000043];
int visited[2000043];
int level[2000043];
void bfs(int x) {
  queue<int> q;
  visited[x] = 1;
  level[x] = 0;
  q.push(x);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < adj[p].size(); i++) {
      if (!visited[adj[p][i]]) {
        level[adj[p][i]] = level[p] + 1;
        q.push(adj[p][i]);
        visited[adj[p][i]] = 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, d;
  cin >> a;
  int s = 0;
  vector<int> v;
  for (int i = 0; i < a; i++) {
    int c;
    cin >> c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  int t = 1;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] >= t) {
      s++;
      t++;
    }
  }
  cout << s << "\n";
  return 0;
}
