#P3375. Network Connection

Network Connection

Description

There are M network interfaces in the wall of aisle of library. And N computers next to the wall need to be connected to the network. A network interface can only connect with one computer at most. To connect an interface with coordinate x with a computer with coordinate y needs |x - y| unit of length of network cable. Your task is to minimize the total length of network cables to be used.

Input

The first line contains two integers M (1 ≤ M ≤ 100000), N (1 ≤ N ≤ 2000, NM). The following M + N lines each contains a integer coordinate. The first M coordinates are corresponding to the network interfaces, and the next N ones corresponding to the computers. All coordinates are arranged in [0, 1000000]. Distinct interfaces may have the same coordinate, so do the computers.

Output

Print an integer, representing minimum length of network cables to be used.

4 2
1
10
12
20
11
15
4

Source

POJ Monthly--2007.09.09, Updog