This range contains 80 numbers (40 in 1-40, and another 40 in -39-0).
We have
S = 1 + 2 + 3 + … + 38 + 39 + 40
S = 40 + 39 + 38 + … + 3 + 2 + 1
==> 2S = (1 + 40) + (2 + 39) + … + (39 + 2) + (40 + 1)
==> 2S = 40 × 41
==> S = 820
and
T = 0 + 1 + 2 + … + 37 + 38 + 39
T = 39 + 38 + 37 + … + 3 + 2 + 1
==> 2T = (0 + 39) + (1 + 38) + … + (38 + 2) + (39 + 0)
==> 2T = 40 × 39
==> T = 780
The average of the numbers in this range is equal to the total divided by the amount of numbers in the range, so
average = (40 + 39 + … + 1 + 0 + (-1) + … + (-38) + (-39))/80
average = (S - T )/80
average = (820 - 780)/80
average = 40/80 = 1/2