403850: GYM101341 E Bonuses and Teleports
Description
On a number axis n teleports are located in the points ti and m bonuses are located in the points bj. Being in the same point with a teleport, one can instantly relocate to another point with the teleport. Being in the same point with a bonus, one can instantly get this bonus.
You are in the point t1 and must collect all the bonuses, and then return back to the point t1. You can move along the number axis in any direction at the speed 1. How much time will it take to collect all the bonuses?
InputThe first line contans two integers n and m separated by a space (1 ≤ n, m ≤ 200000) — the number of teleports and the number of bonuses, correspondingly.
The second line contains n integers ti separated by a space ( - 109 ≤ ti ≤ 109, ti ≤ ti + 1) — coordinates of the teleports in non-decreasing order.
The third line contains m integers bj separated by a space ( - 109 ≤ bj ≤ 109, bj ≤ bj + 1) — coordinates of the bonuses in non-decreasing order.
OutputOutput a single integer — the minimal time required to collect all the bonuses.
ExamplesInput2 4Output
0 10
-1 1 9 11
8Input
2 2Output
0 10
4 6
10Input
1 1Output
1000000000
-1000000000
4000000000