Solution (source code)

= Solution

For a finite <probability distribution>,
$$
H(X)=-\sum_{p_i>0}p_i\log_2p_i,
$$
with $0\log_20=0$. If the positive support has size $s\le n$, apply the given strict <Jensen inequality> to the <random variable> $Z=1/p_X$:
$$
H(X)=\mathbb E\log_2 Z\le\log_2\mathbb EZ=\log_2s\le\log_2n.
$$
Equality requires $s=n$ and $Z$ constant almost surely, so all probabilities are $1/n$. Conversely the uniform distribution attains this bound. Thus $\boxed{H(X)\le\log_2n}$, with exactly that equality case.