Quantum ideal gas - Canonical ensemble - Occupation number summation notation (Huang) (Question at the end, in bold, marked with an b))
For the quantum ideal gas, the hamiltonian (operator) of the system is: 
\begin{align}
\mathcal
H=\sum_{i=1}^N H_i=\sum_{i=1}^N \frac{P_i^2}{2m}
\end{align}
where $N$ is the number of particles.
In the canonical ensemble we have
\begin{align}
\mathcal
\rho = e^{-\beta \mathcal{H}}
\end{align}
where $\rho$ is the density operator and $\beta = \frac{1}{K_BT}$.
The entry $jj$ of the matrix that represents this operator in the basis of eigenvectors of $\mathcal{H}$ is, then:
\begin{align}
\mathcal 
\rho_{jj} = e^{-\beta E_j}
\end{align}
and thus, the partition function is given by:
\begin{align}
Z_N = Tr[\rho]=\sum_{j=1}^\mathcal{N} e^{-\beta E_j}
\end{align}
where $\mathcal{N}$ is the number of eigenvalues $E_j$ of $\mathcal{H}$ (repeated included).
a) 
This is what's written in some Statistical Mechanics books/notes (e.g., Huang):
\begin{align}
Z_N = \sum_{\{n_p\}} e^{-\beta E }
\end{align}
with
\begin{align} 
E=\sum_{\vec{p}} \epsilon_\vec{p} n_\vec{p} \quad , \quad N=\sum_{\vec{p}} n_\vec{p}
\end{align}
where $n_\vec{p}$ is the occupation number (number of particles) corresponding to a configuration with momentum $\vec{p}$ (?) and $\epsilon_\vec{p}$ the respective energy. 
b) 
Is $E_j = E \,$? If so, how can I see that? If not, what exactly does $Z_N$ as written in the books (i.e. the summation as the above) mean?
Addendum:


*

*I thought that if the system is in the state $|\Psi^{(j)} \rangle$, eigenvector of $\mathcal{H}$ associated with $E_j$, then maybe $|\Psi^{(j)} \rangle = |\phi_1^{(j)} \rangle |\phi_2^{(j)} \rangle...|\phi_N^{(j)} \rangle $ (with $|\phi_i^{(j)} \rangle$ being the state of particle $i$ when the system is in the state $|\Psi^{(j)} \rangle$) and, thus, 
\begin{align}
\mathcal
H|\Psi^{(j)} \rangle &= \bigg(\sum_{i=1}^N H_i \bigg) |\phi_1^{(j)} \rangle |\phi_2^{(j)} \rangle...|\phi_N^{(j)} \rangle \\
&= \bigg(\sum_{i=1}^N \epsilon_i^{(j)} \bigg) |\Psi^{(j)} \rangle  
\end{align}


$\qquad$ with $\epsilon_i^{(j)}$ being the eigenvalue of $H_i$ associated with the eigenvector $|\phi_i^{(j)} \rangle$.


*

*Since  $\mathcal{H}|\Psi^{(j)} \rangle = E_j |\Psi^{(j)} \rangle$, we would have:


\begin{align}
\tag{*} E_j = \sum_{i} \epsilon_i^{(j)}
\end{align}


*

*If $n_\vec{p}$ particles have momentum $\vec{p}$, then I guess we could write this as:


\begin{align}
E_j = \sum_{\vec{p}} n_\vec{p}^{(j)} \epsilon_\vec{p}^{(j)} 
\end{align}


*

*Finally, instead of doing a sum over $j$, they decide to do a sum over all possible $n_\vec{p}$, thus getting the formula in the books. Is this correct?


EDIT (reply to glance):
This is what I got:  
Suppose $E_1$ and $E_2$ are eigenvalues of the total hamiltonian $\mathcal{H}$ with $g_{E_1}=2$ and $g_{E_2}=1$. Then, there are two eigenstates $|E_{1_a} \rangle$ and $|E_{1_b} \rangle$ for which 
\begin{align}
\mathcal{H} |E_{1_a} \rangle = E_1|E_{1_a} \rangle \\
\mathcal{H} |E_{1_b} \rangle = E_1|E_{1_b} \rangle 
\end{align}
and one state $|E_{2} \rangle$ for which $\mathcal{H} |E_{2} \rangle = E_2|E_{2} \rangle$.
Each of these states may be written in terms of the states of the particles, $|\epsilon_{i} \rangle$  (eigenstates of $H_i$ with eigenvalues $\epsilon_i$). Say $N=3$ and that, e.g.:  
\begin{align}
& |E_{1_a} \rangle = |\epsilon_{1},\epsilon_{2},\epsilon_{2} \rangle \rightarrow \text{config} \quad \{n_p\}_{1_a}=\{ p_1,p_2,p_2\} \\
& |E_{1_b} \rangle = |\epsilon_{2},\epsilon_{2},\epsilon_{1} \rangle \rightarrow \text{config} \quad \{n_p\}_{1_b}=\{ p_2,p_2,p_1\} \\
& |E_{2} \rangle = |\epsilon_{5},\epsilon_{5},\epsilon_{2} \rangle \rightarrow \text{config} \quad \{n_p\}_2=\{ p_5,p_5,p_2\}
\end{align}
Then, corresponding to $E_1$, we have occupation numbers $n_{p_1}=1$, $n_{p_2}=2$ and $n_{p_k}=0$ $\forall k>2$ and, for $E_2$, occupation numbers $n_{p_2}=1$, $n_{p_5}=2$  and $n_{p_k}=0$ for $k\neq 2,5$.
$Z$ would then be, according to your (2):
\begin{align}
Z &= e^{-\beta (1 \epsilon_1 + 2 \epsilon_2 +  \sum\limits_{k>2} 0 \epsilon_k)} + e^{-\beta (1 \epsilon_1 + 2 \epsilon_2 + \sum\limits_{k>2} 0 \epsilon_k)} + e^{-\beta (1 \epsilon_2 + 2 \epsilon_5 + \sum\limits_{k \neq 2,5} 0 \epsilon_k)} \\
&= 2e^{-\beta (1 \epsilon_1 + 2\epsilon_2)} + e^{-\beta (1\epsilon_2 + 2\epsilon_5)} \\
&= g_{E_1}e^{-\beta E_1} + g_{E_2}e^{-\beta E_2}
\end{align}
 A: The point is that to get the partition function you have to sum over all states, with the usual Boltzmann weight factor $e^{-\beta E}$.
If you label the energy eigenstates of your system with $| n \rangle$ then the partition function will have the form
$$ \tag{1} Z = \sum_n g_n e^{-\beta E_n},$$
where $E_n$ is the energy of the $n$-th state, and $g_n$ is a possibly present degeneracy factor counting the number of states with energy $E_n$ (which in the non-degenerate case is equal to 1 and thus unnecessary).
If you are dealing with a many-particles system one way to label the states is by specifying the configuration $\{ n_j\}_j$, i.e. the occupation number $n_j$ of the $j$-th particle, for every particle $j=1,...,N$, and the partition function can accordingly be written as
$$ \tag{2} Z= \sum_{\{n_j\}} g(\{n_j\}) e^{-\beta E(\{n_j\})}, $$
where it is important to notice that the energy $E$ depends on the configuration $\{n_j\}$.
However, while (2) is usually more practical in these circumstances, one could equally well express the partition function in the form (1).
To try to make it clearer I'll show how we would do this:
let $E_j$ denote the eigenenergies of the total system (so rembember that this $j$ is different from the one used above, which labeled one-particle states). Then the partition function has the form
$$ \tag{3} Z = \sum_j g_j e^{-\beta E_j}.$$
Why is this equal to (2)? Because we are still counting all states, just in a different way. Now $g_j$ is the number of states with total energy $E_j$, i.e. in terms of how the single-particle states are distributed:
$$ g_j = \sum_{\{n_{\textbf p} \}\, | \sum_{\textbf p} \!\epsilon_{\textbf p}=E_j} g( \{n_{\textbf p} \}),$$
where $\epsilon_{\textbf p}$ is the energy of an electron in the state $\textbf p$, and I am now labeling single particle states using their momenta $\textbf p$.
