from collections import deque N = int(input()) A = deque(list(map(int,input().split()))) s = 0 while len(A) > 0: s += abs(A.pop() - A.pop()) print(s)