N = int(input()) A = list(map(int, input().split())) A.sort() Y = -sum(A[:N // 2]) X = sum(A[N // 2:]) print(X - Y)