4. Given a sequence of positive terms $\left\{a_{n}\right\}$ with the sum of the first $n$ terms being $S_{n}$. If $\left\{a_{n}\right\}$ and $\left\{\sqrt{S_{n}}\right\}$ are both arithmetic sequences with the same common difference, then $S_{n}=$ $\qquad$
4. $\frac{n^{2}}{4}$.

Let $a_{n}=a_{1}+(n-1) d\left(a_{1} 、 d>0\right.$ be constants $)$. From the given information, we have
$$
\begin{array}{l}
\sqrt{S_{n}}=\sqrt{a_{1}}+(n-1) d \\
\Rightarrow a_{n}=S_{n}-S_{n-1} \\
\quad=\left(\sqrt{a_{1}}+(n-1) d\right)^{2}-\left(\sqrt{a_{1}}+(n-2) d\right)^{2} \\
\quad=d\left(2 \sqrt{a_{1}}+(2 n-3) d\right) \\
\Rightarrow a_{1}+(n-1) d=d\left(2 \sqrt{a_{1}}+(2 n-3) d\right) \\
\Rightarrow\left\{\begin{array}{l}
2 d \sqrt{a_{1}}-3 d^{2}=a_{1}-d, \\
2 d^{2}=d
\end{array}\right. \\
\Rightarrow a_{1}=\frac{1}{4}, d=\frac{1}{2} \\
\Rightarrow S_{n}=\frac{n^{2}}{4} .
\end{array}
$$