The goal is to add up all the numbers from 22 to 41 inclusive. Sum = 22 + 23 + ... + 40 + 41.
This is an arithmetic progression. More generally, we might have:
Sum = a + (a+d) + (a+2d) + ... (a+(n-3)d) +(a+(n-2)d)+(a+(n-1)d)
where there are n terms, the first of which is "a" and the same difference, "d", is added on to each successive term.
Let's rewrite the sum and below it write the same thing, but with the terms written in reverse order:
Sum = a + (a+d) + (a+2d) + ... + (a+(n-3)d) +(a+(n-2)d)+(a+(n-1)d)
Sum = (a+(n-1)d)+ (a+(n-2)d) + (a+(n-3)d) +... + (a+2d) + (a+d) + a
Now add up the two series term by term:
2*Sum = (2a+(n-1)d) + (2a+(n-1)d)+(2a+(n-1)d)+ ... +(2a+(n-1)d)+(2a+(n-1)d)+(2a+(n-1)d)
or, setting b = a+(n-1)d, the last term in the original series, we have:
2*Sum = (a+b) + (a+b) + (a+b) + ... + (a+b) + (a+b) + (a+b)
There are n terms on the right-hand side, all equal to a+b, so
2*Sum = n(a+b)
so that
Sum = n(a+b)/2
In the original question, n = 20, a = 22 and b = 41.
Does this make it clearer?