LearnPy Hub
← Arena
EasyRating 900

Even-Sized Teams

Split n students into teams of two. Two students can be a team only if their skills are equal. A skill goes up by 1 for each problem solved. Print the fewest problems students must solve so everyone has a teammate (n is even).

Input

n, then n skills.

Output

One integer.

Sample 1

Input
6
5 10 2 3 14 5
Output
5

Sample 2

Input
2
1 100
Output
99
solution.py
Output appears here
Even-Sized Teams · Python Arena problem · LearnPy Hub