4. Given the sequence $\left\{a_{n}\right\}$ with the sum of the first $n$ terms as $S_{n}$, and
$$
a_{1}=3, S_{n}=2 a_{n}+\frac{3}{2}\left((-1)^{n}-1\right) \text {. }
$$

If $\left\{a_{n}\right\}$ contains three terms $a_{1} 、 a_{p} 、 a_{q}(p 、 q \in$ $\left.\mathbf{Z}_{+}, 1<p<q\right)$ that form an arithmetic sequence, then $q-p=$
4. 1 .

Given $S_{n}=2 a_{n}+\frac{3}{2}\left((-1)^{n}-1\right)$
$$
\Rightarrow S_{n-1}=2 a_{n-1}+\frac{3}{2}\left((-1)^{n-1}-1\right)(n \geqslant 2) \text {. }
$$

Subtracting the two equations yields $a_{n}=2 a_{n-1}-3(-1)^{n}(n \geqslant 2)$.
Let $b_{n}=\frac{a_{n}}{(-1)^{n}}$. Then
$$
\begin{array}{l}
b_{n}=-2 b_{n-1}-3 \\
\Rightarrow b_{n}+1=-2\left(b_{n-1}+1\right) \\
\quad=(-2)^{n-1}\left(b_{1}+1\right)=(-2)^{n} \\
\Rightarrow b_{n}=(-2)^{n}-1 \\
\Rightarrow a_{n}=2^{n}-(-1)^{n} .
\end{array}
$$

Assume there exists a positive integer $c$, such that $a_{1} 、 a_{n} 、 a_{n+c}$ form an arithmetic sequence. Then
$$
\begin{array}{l}
2\left(2^{n}-(-1)^{n}\right)=2^{n+c}-(-1)^{n+c}+3 \\
\Rightarrow 2^{n+1}\left(2^{c-1}-1\right)+(-1)^{n}\left(2-(-1)^{c}\right)+3=0 .
\end{array}
$$

Clearly, the above equation holds if and only if $c=1$, and $n$ is a positive odd number.
Thus, $p=n, q=n+1 \Rightarrow q-p=1$.