RedCapeFlyingCat is standing at coordinate on a number line and wants to reach the goal at coordinate .
There is a wall at coordinate . At first, RedCapeFlyingCat cannot pass through coordinate . There is also a hammer at coordinate : once RedCapeFlyingCat arrives at coordinate , the hammer is picked up, and from then on the wall can be broken and passed through.
Determine whether RedCapeFlyingCat can reach the goal. If so, find the minimum total distance that has to be traveled.
In the sample test case, , , and . The wall is farther away than the goal, so it is not in the way: RedCapeFlyingCat goes straight from to . The total distance is .
Two more examples (they are not given as sample test cases):
-1.Three lines, each with one integer:
One line containing one integer: the minimum total distance RedCapeFlyingCat has to travel to reach the goal.
If the goal cannot be reached, output -1.