4. A permutation $a_{1}, a_{2}, \cdots, a_{n}$ of $1,2, \cdots, n(n \geqslant 2)$ is called a "good permutation" if there exists a unique $i \in\{2,3, \cdots, n\}$ such that $a_{i}<a_{i-1}$. If the number of good permutations is $p_{n}$, then $\sum_{i=2}^{n} \frac{p_{i}}{2^{i}}=$ $\qquad$
4. $n-3+\frac{n+3}{2^{n}}$.

From the problem, we know
$$
a_{1}a_{i}, a_{i}a_{i}$, thus, we only need to exclude the case where the selected set is exactly $\{1,2, \cdots, i-1\}$.
$$
\begin{array}{l}
\text { Then } p_{n}=\sum_{i=2}^{n}\left(\mathrm{C}_{n}^{i-1}-1\right)=2^{n}-n-1 . \\
\text { Therefore, } \sum_{i=2}^{n} \frac{p_{i}}{2^{i}}=n-1-\sum_{i=2}^{n} \frac{i+1}{2^{i}} \\
=n-1-\sum_{i=1}^{n-1} \frac{i+2}{2^{i}}+\sum_{i=2}^{n} \frac{i+1}{2^{i}} \\
=n-1-\frac{3}{2}+\frac{n+1}{2^{n}}-\sum_{i=2}^{n-1} \frac{1}{2^{i}} \\
=n-3+\frac{n+3}{2^{n}} .
\end{array}
$$