// Arup Guha
// 4/26/2018
// Solution to 2018 March USACO Silver Problem: Lemonade Line

import java.util.*;
import java.io.*;

public class lemonade {

	public static void main(String[] args) throws Exception {

		BufferedReader stdin = new BufferedReader(new FileReader("lemonade.in"));
		int n = Integer.parseInt(stdin.readLine().trim());

		// Read and sort data in reverse.
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		ArrayList<Integer> vals = new ArrayList<Integer>();
		for (int i=0; i<n; i++)
			vals.add(Integer.parseInt(tok.nextToken()));
		Collections.sort(vals);
		Collections.reverse(vals);

		// This is our greedy, if the ith cow in this sorted order 
		// needs a better, place, then we can't satisfy them.
		int res = 0;
		for (int i=0; i<n; i++)
			if (vals.get(i) >= res)
				res++;

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("lemonade.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}

