Spectral theory of tori, via analytic number theory