Here's some calculations (albeit late night ones so excuse any nonsense).
These are calculated assuming no wind, no temperature variations, no losses and starting and ending at a constant speed (ie. no acceleration).
Google tells me the mean radius of the earth is 6,371.009km, so to travel half way around the world (half the circumference) would be approx 20015.09km at sea level. To do the same at sea level +40000ft would mean a radius of approx 6283km and therefore an A to B distance of 20052.79km.
To put a slightly difference spin on it, let's assume we need to travel A > B in 30 hours. At sea level this would require a speed of roughly 667.17km/h and at 40000ft would require a speed of roughly 668.43km/h.
Hope this makes some sense!