8 Let $p$ be a given positive even number, and the set $A_{p}=\left\{x \mid 2^{p}<x<2^{p+1}, x=\right.$ $3 m, m \in \mathbf{N}\}$ . The sum of all elements in $A_{p}$ is $\qquad$ .
$82^{2 p-1}-2^{p-1}$ Hint:
$$
\begin{array}{c}
2^{p}+2 \equiv(-1)^{p}+2 \equiv 1+2 \equiv 0(\bmod 3) . \\
2^{p+1}-2 \equiv 2(-1)^{p}-2 \equiv 2-2 \equiv 0(\bmod 3) .
\end{array}
$$

The elements in set $A_{p}$ form an arithmetic sequence with a common difference of 3, the first term being $2^{p}+2$, and the last term being $2^{p+1}-2$.
Let there be $n$ terms, then
$$
2^{p+1}-2=2^{p}+2+3(n-1),
$$

we get $n=\frac{2^{p}-1}{3}$. The sum of all elements in set $A_{p}$
$$
S=\frac{n\left(a_{1}+a_{n}\right)}{2}=\frac{2^{p}-1}{3} \cdot \frac{\left(2^{p}+2+2^{p+1}-2\right)}{2}=2^{2 p-1}-2^{p-1} .
$$