403850: GYM101341 E Bonuses and Teleports

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Bonuses and Teleportstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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?

Input

The 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.

Output

Output a single integer — the minimal time required to collect all the bonuses.

ExamplesInput
2 4
0 10
-1 1 9 11
Output
8
Input
2 2
0 10
4 6
Output
10
Input
1 1
1000000000
-1000000000
Output
4000000000

加入题单

上一题 下一题 算法标签: