14. In the sequence $\left\{a_{n}\right\}$, $S_{n}$ is the sum of the first $n$ terms, $S_{n}=\frac{n}{2}\left(a_{1}+a_{n}\right)$, find the general formula for $a_{n}$.
14. Given $S_{n}=\frac{n}{2}\left(a_{1}+a_{n}\right)$, let $S_{n-1}=\frac{n-1}{2}\left(a_{1}+a_{n-1}\right)$, subtracting the two equations gives $2 a_{n}=n\left(a_{1}+a_{n}\right)-$ $(n-1)\left(a_{1}+a_{n-1}\right)$, simplifying yields $(n-2)\left(a_{n}-a_{1}\right)=(n-1)\left(a_{n-1}-a_{1}\right)$, hence $\frac{a_{n}-a_{1}}{n-1}=\frac{a_{n-1}-a_{1}}{(n-1)-1}=$ $\cdots=\frac{a_{2}-a_{1}}{1}$. Let $a_{2}-a_{1}=d$, so $a_{n}-a_{1}=(n-1) d$, which means $a_{n}=a_{1}+(n-1) d$.