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

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:

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!