Codeforces round 636 problem E (div 3) help needed

Hey can anyone please explain the editorial of problem E in codeforces round 636 div 3 in detail?
problem :

Trying drawing it out on a graph. You will observe that you need 2 paths to achieve the task, which will always diverge at a point say B -> X to X -> A and X -> C . Calculate a X such that cost is minimized.

hey thanks!