You build your track dead straight - like, not conforming to the surface direct through the crust straight. Now the train accelerates downhill for the first half of the journey, and decelerates uphill for the second, neatly coming to a stop at the destination. Oddly enough, in the spherical cow universe where you build this, all the maths cancels such that you get a constant travel time regardless of the start and end locations. On earth it's about 40 minutes