I have a set of $n$ ordered nonnegative integers, $a_1\geqslant a_2\geqslant\ldots\geqslant a_n$. Let $s$ be the integer defined by
$$s:=\max\limits_{i}\left(\min\left\{i, a_i\right\}\right).$$
From the given integers, $a_1, \ldots,, a_n$, find the number of elements $X$ that are less than $s$? Or alternatively, find all $a_i$ such that $a_i<s$?
Examples:
$a_1=10, a_2=8, a_3=4, a_4 =2$. I have $s=3$ and there is only one which is less than $3$, i.e., $a_4$. Hence, $X=1$.
$a_1=10, a_2=5, a_3=3, a_4 =2, a_5=1$. I have $s=3$ and there are two which are less than $3$, i.e., $a_4$ and $a_5$. Hence, $X=2$.
Can I found a general formula for $X$?
My question comes when I was trying to solve this problem. Given $n$ as input, I am trying to construct a sequence of $a_1$, $a_2$, $\ldots$, $a_n$ that gives me the largest $$ \binom{n-X}{s}. $$
If I find $X$, then I think I could find a sequence that gives the highest such number since we know that the binomial coefficient $n$ choose $p$ is maximum for $p$ equals $n/2$.
NB. In the title, I used the term h-index because $s$ defines exactly the h-index.