#!/usr/bin/env python3

# -*- coding: utf-8 -*-



n = int(input().strip())

a = sorted(list(map(int, input().strip().split(" "))), reverse=True)

print((sum(a[::2]) - sum(a[1::2])))

def solve(string):

    n, *a = list(map(int, string.split()))

    a = sorted(a, reverse=True)

    return str(sum(a[::2]) - sum(a[1::2]))





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input().strip())
a = sorted(list(map(int, input().strip().split(" "))), reverse=True)
print((sum(a[::2]) - sum(a[1::2])))

def solve(string):
    n, *a = list(map(int, string.split()))
    a = sorted(a, reverse=True)
    return str(sum(a[::2]) - sum(a[1::2]))


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

-#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -n = int(input().strip()) -a = sorted(list(map(int, input().strip().split(" "))), reverse=True) -print((sum(a[::2]) - sum(a[1::2]))) +def solve(string): +    n, *a = list(map(int, string.split())) +    a = sorted(a, reverse=True) +    return str(sum(a[::2]) - sum(a[1::2])) + + +if __name__ == "__main__": +    print((solve("\n".join([eval(input()), eval(input())]))))