I did this a few months ago (although I arrived from Brussels rather than Madrid) and contrary to the above posters, I think you will definitely need to keep moving, especially if your flight is even the slightest bit late.
The directions are not signposted as clearly as they could be, by the way.