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.
for all integer from to .
The first line contains an integer, .
The second line contains integers, the being .
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.
3 1 7 4 6 10 9