BPC 1 J3 - Group Project
View as PDFYou 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
Comments