A variational principle for scattering phase shifts