Nails
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Some nails are hammered on a straight plank. Any two nails can be joined by a thread. Connect some pairs of nails with a thread, so that to each nail will be tied with at least one thread, and the total length of all threads will be minimal.
Input
The first line contains the number of nails . The next line contains numbers — the coordinates of all the nails (non-negative integers not exceeding ).
Output
Print the minimum total length of all threads.
Examples
Input #1
Answer #1
Submissions 8K
Acceptance rate 43%