# Total energy of free electron gas

Hello everyone! I encountered a problem about the specific heat of electronic gas and I do not understand a formula... so the problem says that experimentally it has been shown that the specific heat of the conduction electrons at constant volume in metals depends on temperature, and the experimental
value at room temperature is about two orders of magnitude lower than its classical
counterpart. This is because the electrons obey the quantum statistics rather than
classical statistics. According to the quantum theory, for a metallic material the
density of states of conduction electrons (the number of electronic states per unit
volume and per unit energy) is proportional to the square root of electron energy ,
then the number of states within energy range for a metal of volume V can be
written as:
dS = E^(1/2)* C* V *dE
where C is the normalization constant, determined by the total number of electrons of
the system.
The probability that the state of energy E is occupied by electron is f(E) (it is an exponential formula, not really relevant for what I am about to ask), f(E)is called Fermi distribution function.

Now, my question is the following:

Why is the total energy of the system:
U = ∫ E * f(E) * dS ?

I am new into probability , but I have studied a little and didn't find exactly how to derive the formula. I thought at first that the total energy of the electrons is U = ∫ E * dN ( where dN is the number of electrons with energy E). After that I tried to equal dN with f(E)*dS, so I said that the probaility to find an electron within the energetic range E and E+dE is dP = f(E)*dE and this led to dN = dS/dE * dP. So the number of electrons is the probability times the density of states?
I am not convinced that my answer is corect because after the energy formula arrives another formula which says that the total number of electrons is N = C *V * ∫ E^(1/2) * dE = ∫ dS.
So what is the logic behind these formulas?