BPC 1 J3 - Group Project

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 512M

Author:
Problem type

You are a teacher deciding on pairs for a group project. You have students that are given a quality score . For each pair, you will receive complaints, where is the difference in quality between the two students. Output the minimum number of complaints you can receive.

Constraints

for all integer from to .

Input Specification

The first line contains an integer, .

The second line contains integers, the being .

Output Specification

Output a single line containing an integer, the number of complaints if you optimally pair students to minimize complaints.

Note: the answer might not fit in a 32-bit integer.

Sample Input

3
1 7 4 6 10 9

Sample Output

5