Variational principle for the chemical potential in the Thomas-Fermi model