The answer is 0 because if you add up the difference in the numbers than you'll see that they just cancel each other out.
The total distance traveled by the ball is 40 meters, while the total displacement is 0 meters since it returns to its starting point. Each step of the journey is accounted for in the distance, while the displacement measures the straight-line distance from start to finish. Since the ball ended where it started, the displacement is zero.
;