Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E2. Guard Duty (medium)

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputPrincess Heidi decided to give orders to all her *K* Rebel ship commanders in person. Unfortunately, she is currently travelling through hyperspace, and will leave it only at *N* specific moments *t*_{1}, *t*_{2}, ..., *t*_{N}. The meetings with commanders must therefore start and stop at those times. Namely, each commander will board her ship at some time *t*_{i} and disembark at some later time *t*_{j}. Of course, Heidi needs to meet with all commanders, and no two meetings can be held during the same time. Two commanders cannot even meet at the beginnings/endings of the hyperspace jumps, because too many ships in one position could give out their coordinates to the enemy.

Your task is to find minimum time that Princess Heidi has to spend on meetings, with her schedule satisfying the conditions above.

Input

The first line contains two integers *K*, *N* (2 ≤ 2*K* ≤ *N* ≤ 500000, *K* ≤ 5000). The second line contains *N* distinct integers *t*_{1}, *t*_{2}, ..., *t*_{N} (1 ≤ *t*_{i} ≤ 10^{9}) representing the times when Heidi leaves hyperspace.

Output

Output only one integer: the minimum time spent on meetings.

Examples

Input

2 5

1 4 6 7 12

Output

4

Input

3 6

6 3 4 2 5 1

Output

3

Input

4 12

15 7 4 19 3 30 14 1 5 23 17 25

Output

6

Note

In the first example, there are five valid schedules: [1, 4], [6, 7] with total time 4, [1, 4], [6, 12] with total time 9, [1, 4], [7, 12] with total time 8, [1, 6], [7, 12] with total time 10, and [4, 6], [7, 12] with total time 7. So the answer is 4.

In the second example, there is only 1 valid schedule: [1, 2], [3, 4], [5, 6].

For the third example, one possible schedule with total time 6 is: [1, 3], [4, 5], [14, 15], [23, 25].

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/22/2018 11:34:42 (d3).

Desktop version, switch to mobile version.

User lists

Name |
---|