# Understanding of formula for arithmetic progression

A arithmetic progression is defined by:

$$\begin{cases} a_1=a_1 \\ a_n= a_{n-1}+d \end{cases}$$

I can't understand this passage from a algebra book about arithmetic progression. The formula is $$S=\frac{(a_r+a_s)+(r-s+1)}{2}$$ and it's the formula used to find the sum of all the terms in a arithmetic progression from $a_r$ to $a_s$ and here is the demonstration:

$$a_r+a_s=(a_{r+1}-d)+(a_{s-1}+d)=a_{r+1}+a_{s-1}\ \text{and so}$$ $$2S=2(a_r+a_{r+1}+a_{r+2}+\cdots+a_{s-2}+a_{s-1}+a_{s})=$$ $$= (a_r+a_{s})+(a_{r+1}+a_{s-1})+\cdots +(a_{s-1}+a_{r+1})+(a_{s}+a_{r})=$$ Now here's the passage I don't understand; from the last formula: $$S=\frac{(a_{r}+a_{s})(r-s+1)}2$$

Can somebody explain this to me?

by using $a_r+a_s=a_{r+1}+a_{s-1}$ from above successively.