n = int(input())
a = list(map(int,input().split()))
a.sort()
cnt=0
for i in range(n):
    if i%2==0:cnt+=a[i]
    else:cnt-=a[i]
print(cnt)