Coins and Boxes

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

There are NN boxes and NN coins on the coordinate line. The coordinate of the ii-th box is B_iB\_i, and the coordinate of the jj-th coin is C_jC\_j. You are starting at the point with coordinate 00, and can move freely along the coordinate line.

If you go to a point with a coin, you can pick up that coin. You can carry as many coins as you like. If you go to a point with the box, you can utilize one coin and open the box (but you are not forced to do that). You cannot pick up the coin that was already picked up, or open the box that is already opened.

You want to open all NN boxes. Find the minimum distance you need to travel to achieve your goal.

입력

The first line of input contains one integer NN (1N1051 \le N \le 10^5).

The second line contains NN integers B_1,B_2,,B_NB\_1, B\_2, \ldots, B\_N. The ii-th of those integers is coordinate of the ii-th box (1B_i1091 \le B\_i \le 10^9, B_i<B_i+1B\_i < B\_{i+1} for 1i<N1 \le i < N).

The third line contains NN integers C_1,C_2,,C_NC\_1, C\_2, \ldots, C\_N. The ii-th of those integers is coordinate of the ii-th coin (1C_i1091 \le C\_i \le 10^9, C_i<C_i+1C\_i < C\_{i+1} for 1i<N1 \le i < N).

출력

Print one integer: the minimum distance you need to travel to open all boxes.