N = int(input()) A = sorted(list(map(int, input().split()))) first, second = 0, 0 for i in range(N//2): second += -A[i] for i in range(N//2, N): first += A[i] print(first-second)