4. In the arithmetic sequence $\left\{a_{n}\right\}$, it is known that $\left|a_{5}\right|=\left|a_{11}\right|, d>0$, the positive integer $n$ that makes the sum of the first $n$ terms $S_{n}$ take the minimum value is $\qquad$ .
4. 7 or 8.

Given $\left|a_{5}\right|=\left|a_{11}\right|$, and $d>0$, so $a_{11}>a_{5}$. Therefore, $a_{5}=-a_{11}$, which means $a_{5}+a_{11}=2 a_{8}=0, a_{8}=0$. Hence $a_{1}<a_{2}<a_{3}<\cdots<a_{7}<0, S_{7}=S_{8}$ is the smallest, $n=7$ or 8.