fork download
  1. #88B
  2. def main():
  3. n = int(input())
  4. lst = [ int(num) for num in input().split()] #3 8 7 1
  5. lst = sorted(lst, reverse=True)
  6. a = sum(lst[0:n:2])
  7. b = sum(lst[1:n:2])
  8. print(a-b)
  9.  
  10.  
  11. main()
  12.  
  13.  
Success #stdin #stdout 0.02s 9244KB
stdin
3
2 7 4

stdout
5