#include <iostream>
#include <algorithm>
using namespace std;
int num[100010];
int getindex(int low, int high, int goal)
{
int mid;
while(low < high)
{
mid = (low + high) / 2;
if(num[mid] > goal)
{
high = mid;
}
else
{
low = mid + 1;
}
}
return high;
}
int main()
{
int n;
scanf("%d", &n);
int i;
for(i = 1; i <= n; i++)
{
scanf("%d", &num[i]);
}
sort(num + 1, num + n + 1);
int index, count;
for(i = n; i >= 0; i--)
{
index = getindex(1, n + 1, i);
count = n + 1 - index;
if(count >= i)
{
break;
}
}
printf("%d\n", i);
system("pause");
return 0;
}