I'll give you an example.

Take a rider+bike weighing 100 kg.

Let's say this fictional rider is capable of putting out a maximum of 200 W.

His total CdA is 0.4. His bike's Cfr is 0.006.

Let's say he rides 100 km over three different courses.

Course #1 is a completely flat road. No climbs or descents at all.

His average speed is 31 km/h.

The total energy spent is 2640 kcal (or around 820 kcal/hour).

Course #2 is a course with 25 km flat road, 25 km with a 5% climb, 25 km with a 5% descent (one hell of a ride!) and finally 25 km of flat road.

Here, the average speed drops to 24.7 km/h, but the energy spent goes up to 3320 kcal!

Course #3 is a 10% climb for 50 km, followed by a 10% descent for the remaining 50 km (wohooo!!!).

Average speed is now down to a snail-like 12.7 km/h, but the energy required is a massive 6490 kcal!!!

He begins and ends at the same elevation in all three rides, yet the differences in energy and averages are staggering!

Convinced?