We are interested in the maximum number of electrons in all the energy levels
n=4 and l=0
That means that we have for;
Thus when n=4 and l=0, then the highest orbital is 4s which has a maximum of 2 electrons.
If we now re-write the electron configuration of Q, we will have;
1s2, 2s2, 2p6, 3s2, 3p6, 3d10, 4s2
Thus the total number of electrons is 2+2+6+2+6+10+2 = 30 electrons