  Invariant ensemble, which are characterised by the joint distribution of
eigenvalues $P(\lambda_1,\ldots,\lambda_N)$, play a central role in random
matrix theory. We consider the truncated linear statistics $L_K = \sum_{n=1}^K
f(\lambda_n)$ with $1 \leq K \leq N$, $\lambda_1 > \lambda_2 > \cdots >
\lambda_N$ and $f$ a given function. This quantity has been studied recently in
the case where the function $f$ is monotonous. Here, we consider the general
case, where this function can be non-monotonous. Motivated by the physics of
cold atoms, we study the example $f(\lambda)=\lambda^2$ in the Gaussian
ensembles of random matrix theory. Using the Coulomb gas method, we obtain the
distribution of the truncated linear statistics, in the limit $N \to \infty$
and $K \to \infty$, with $\kappa = K/N$ fixed. We show that the distribution
presents two essential singularities, which arise from two infinite order phase
transitions for the underlying Coulomb gas. We further argue that this
mechanism is universal, as it depends neither on the choice of the ensemble,
nor on the function $f$.
