Arithmetic sum to nth term

I know that in an arithmetic progression, the value of the nth term is given by:

$\displaystyle u_{n}=a+(n-1)d$

where a is the first term and d is the common difference. This is pretty straightforward. I don't understand how this is then used to obtain the formula for the sum of the first n terms:

$\displaystyle S_{n}=\frac{n}{2} [2a+(n-1)d]$

Can someone please explain where this equation comes from, and how it is derived? I'm guessing it's not a big leap from the first one I gave, but it's big enough for me to to work it out. Cheers!