There are $n$ students in a university. The number of students is even. The $i$-th student has programming skill equal to $a_i$. 

The coach wants to form $\frac{n}{2}$ teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).

Students can solve problems to increase their skill. One solved problem increases the skill by one.

The coach wants to know the minimum total number of problems students should solve to form exactly $\frac{n}{2}$ teams (i.e. each pair of students should form a team). Your task is to find this number.


-----Input-----

The first line of the input contains one integer $n$ ($2 \le n \le 100$) — the number of students. It is guaranteed that $n$ is even.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$), where $a_i$ is the skill of the $i$-th student.


-----Output-----

Print one number — the minimum total number of problems students should solve to form exactly $\frac{n}{2}$ teams.


-----Examples-----
Input
6
5 10 2 3 14 5

Output
5

Input
2
1 100

Output
99



-----Note-----

In the first example the optimal teams will be: $(3, 4)$, $(1, 6)$ and $(2, 5)$, where numbers in brackets are indices of students. Then, to form the first team the third student should solve $1$ problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve $4$ problems so the answer is $1 + 4 = 5$.

In the second example the first student should solve $99$ problems to form a team with the second one.

Source: codeforces | Difficulty: EASY
Tags: Sorting


Solutions:
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
c = 0
for i in range(1, n, 2):
	c += l[i] - l[i - 1]
print(c)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
for i in range(n // 2):
	ans += a[i * 2 + 1] - a[i * 2]
print(ans)


input()
n = list(map(int, input().split()))
n.sort()
c = 0
for i in range(0, len(n), 2):
	c += n[i + 1] - n[i]
print(c)


n = int(input())
t = []
c = []
ta = input().split()
for i in range(n):
	ta[i] = int(ta[i])
	t.append(ta[i])
t.sort()
for i in range(len(t) // 2):
	if n == 2:
		c.append(abs(t[i + 1] - t[i]))
	elif sum(t) // len(t) == t[0]:
		c.append(0)
	elif i == 0 and n != 2:
		c.append(abs(t[i + 1] - t[i]))
		t[i] = t[i] + c[0]
	else:
		c.append(t[i * 2 + 1] - t[i * 2])
print(sum(c))


def solve(arr):
	ans = 0
	sorted_arr = list(sorted(arr))
	for i in range(0, len(sorted_arr), 2):
		ans += sorted_arr[i + 1] - sorted_arr[i]
	return ans

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr))
main()


n = int(input())
arr = [int(num) for num in input().split()]
arr.sort()
a = 0
for i in range(0, n, 2):
	a += arr[i + 1] - arr[i]
print(a)


N = int(input())
l = [int(i) for i in input().split()]
l.sort()
k = 0
m = 0
while k < N - 1:
	m += l[k + 1] - l[k]
	k += 2
print(m)


int(input())
lst = [int(j) for j in input().split()]
lst.sort()
prob = 0
k = 0
for i in range(len(lst) - 1):
	if i + k + 1 < len(lst):
		prob += abs(lst[i + k] - lst[i + k + 1])
		k += 1
print(prob)


m = int(input())
ll = list(map(int, input().rstrip().split()))
ll.sort()
i = 0
s = 0
while 2 * i < m:
	s = s + ll[2 * i + 1] - ll[2 * i]
	i = i + 1
print(s)


n = int(input())
ar = list(map(int, input().split()))
ar.sort()
ans = 0
i = 0
while i < n:
	if ar[i] != ar[i + 1]:
		ans = ans + ar[i + 1] - ar[i]
		i += 2
	elif ar[i] == ar[i + 1]:
		i += 2
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
sum = 0
for i in range(0, len(a), 2):
	sum += abs(a[i] - a[i + 1])
print(sum)


n = int(input())
Q = map(int, input().split())
L = list(Q)
L.sort()
sum_num = 0
k = 0
while k < n:
	sum_num += L[k + 1] - L[k]
	k += 2
print(sum_num)


import math, sys
from fractions import *

def mp():
	return list(map(int, input().split()))

def main():
	n = int(input())
	a = sorted(mp())
	i = 0
	ans = 0
	while i < n:
		ans += a[i + 1] - a[i]
		i += 2
	print(ans)
deb = 0
if deb:
	file = open('input.txt', 'w')
else:
	input = sys.stdin.readline
main()


n = int(input())
skills = list(map(int, input().split()))
t = n // 2
skills.sort()
topSkills = []
for i in range(n // 2):
	topSkills.append([skills[-1]] + [skills[-2]])
	skills = skills[:-2]
sum = 0
for i in topSkills:
	sum += abs(i[0] - i[1])
print(sum)


n = int(input())
list = [int(i) for i in input().strip().split(' ')]
sum = 0
list.sort()
for i in range(0, len(list) - 1, 2):
	sum += list[i + 1] - list[i]
print(sum)


from collections import defaultdict as dc
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
c = 0
p = []
q = dc(int)
for i in range(n):
	q[a[i]] = q[a[i]] + 1
w = list(set(a))
l = len(w)
for i in range(l):
	if q[w[i]] % 2 != 0:
		p.append(w[i])
l = len(p)
i = 0
while i < l - 1:
	c = c + (p[i + 1] - p[i])
	i = i + 2
print(c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = 0
for i in range(n // 2):
	s += a[2 * i + 1] - a[2 * i]
print(s)


from collections import defaultdict
n = int(input())
x = defaultdict(lambda : 0)
arr = [int(item) for item in input().split(' ')]
for item in arr:
	x[item] += 1
remaining = []
for (key, value) in x.items():
	if value % 2:
		remaining.append(key)
remaining.sort()
cost = 0
for i in range(0, len(remaining) // 2):
	i *= 2
	cost += remaining[i + 1] - remaining[i]
print(cost)


def min_a(a):
	k = min(a)
	del a[a.index(min(a))]
	k = abs(k - min(a))
	del a[a.index(min(a))]
	return k
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n // 2):
	ans += min_a(a)
print(ans)


n = int(input())
a = sorted([int(i) for i in input().split()])
ans = 0
while len(a) != 0:
	if a[0] in a[1:]:
		del a[1 + a[1:].index(a[0])]
		del a[0]
	else:
		j = min([(abs(a[0] - a[1:][i]), i) for i in range(len(a[1:]))])
		ans += j[0]
		del a[0]
		del a[j[1]]
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
count = 0
for i in range(0, n - 1, 2):
	count = count + (a[i + 1] - a[i])
print(count)


n = int(input())
l = [int(num) for num in input().split()]
l.sort()
s = 0
for i in range(0, n, 2):
	s += l[i + 1] - l[i]
print(s)


n = int(input().strip())
students = [s for s in map(int, input().strip().split())]
for i in range(n):
	for j in range(n - i - 1):
		if students[j] > students[j + 1]:
			t = students[j]
			students[j] = students[j + 1]
			students[j + 1] = t
acc = 0
for i in range(0, n, 2):
	acc += abs(students[i] - students[i + 1])
print(acc)


import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(0, n - 1, 2):
	ans += abs(a[i] - a[i + 1])
print(ans)


n = int(input())
a = sorted([int(i) for i in input().split()])
diff = 0
for i in range(0, n - 1, 2):
	diff += a[i + 1] - a[i]
print(diff)


n = int(input())
a = [int(i) for i in input().split()]
ct = 0
a = sorted(a)
i = 0
while i < n - 1:
	ct += a[i + 1] - a[i]
	i += 2
print(ct)


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
ans = 0
while i < n:
	ans += a[i + 1] - a[i]
	i += 2
print(ans)


(a, d, c) = (input(), sorted([int(i) for i in input().split()]), 0)
while len(d):
	c += d.pop() - d.pop()
print(c)


n = int(input())
students = [int(x) for x in input().split()]
students.sort()
total = 0
for i in range(0, n, 2):
	total += abs(students[i] - students[i + 1])
print(total)


def quickOld(v, st, dr):
	piv = v[st + (dr - st) // 2]
	i = st
	j = dr
	while i <= j:
		while i < dr and v[i] < piv:
			i += 1
		while j > st and v[j] > piv:
			j -= 1
		if i <= j:
			temp = v[i]
			v[i] = v[j]
			v[j] = temp
			i += 1
			j -= 1
	if i < dr:
		quickOld(v, i, dr)
	if j > st:
		quickOld(v, st, j)
n = input()
cmd = input()
v = cmd.split(' ')
for i in range(len(v)):
	v[i] = int(v[i])
quickOld(v, 0, len(v) - 1)
rez = 0
for i in range(1, len(v), 2):
	rez += v[i] - v[i - 1]
print(rez)


n = input()
lis = input().split()
lis.sort(key=int)
even = lis[::2]
odd = lis[1::2]
even = [int(i) for i in even]
odd = [int(i) for i in odd]
e_sum = sum(even)
o_sum = sum(odd)
diff = abs(e_sum - o_sum)
print(diff)


import math
n = int(input())
arr = list(map(int, input().split()))
f = [0] * 102
for i in arr:
	f[i] += 1
p = []
ans = 0
for i in range(102):
	if f[i] != 0 and f[i] % 2 == 1:
		p.append([i, f[i] % 2])
p = sorted(p, key=lambda item: item[0])
for i in range(0, len(p) - 1, 2):
	ans += abs(p[i][0] - p[i + 1][0])
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
c = 0
for i in range(1, n, 2):
	c = c + a[i] - a[i - 1]
print(c)


(n, a, k) = (int(input()), sorted(map(int, input().split())), 0)
for i in range(0, n, 2):
	k += a[i + 1] - a[i]
print(k)


t = int(input())
l = list(map(int, input().split(' ')))
l.sort()
s = 0
for i in range(1, t, 2):
	s += l[i] - l[i - 1]
print(s)


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split(' ')))
a.sort()
c = len(a)
o = 0
b = 0
while o < c:
	b += a[o + 1] - a[o]
	o += 2
print(b)


n = int(input())
l = [int(x) for x in input().split()]
diff = 0
l.sort()
for i in range(0, len(l), 2):
	diff += l[i + 1] - l[i]
print(diff)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
arr.sort()
for i in range(0, n, 2):
	ans += arr[i + 1] - arr[i]
print(ans)


n = int(input())
arr = list(map(int, input().split()[:n]))
arr = sorted(arr)
count = 0
for i in range(1, n, 2):
	a = int(arr[i])
	b = int(arr[i - 1])
	count += a - b
print(count)


t = 1
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = [-a[2 * i] + a[2 * i + 1] for i in range(n // 2)]
	print(sum(ans))


n = int(input())
A = list(map(int, input().split()))
A.sort()
res = []
for i in range(0, n, 2):
	res.append(A[i + 1] - A[i])
print(sum(res))


n = int(input())
a = list(map(int, input().split()))
left = 0
right = n - 1
flag = 1
while left < right and flag != 0:
	flag = 0
	for i in range(left, right):
		if a[i] > a[i + 1]:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			flag = 1
	right -= 1
	for i in range(right, left, -1):
		if a[i] < a[i - 1]:
			(a[i], a[i - 1]) = (a[i - 1], a[i])
			flag = 1
	left += 1
i = 0
sum = 0
while i < n - 1:
	if a[i] == a[i + 1]:
		i += 1
	else:
		sum += a[i + 1] - a[i]
		i += 1
	i += 1
print(sum)


n = int(input())
k = input().split()
for i in range(n):
	k[i] = int(k[i])
k.sort()
for i in range(n):
	if i >= len(k):
		break
	if k[i] == k[i - 1]:
		del k[i - 1:i + 1]
s = 0
for i in range(1, len(k), 2):
	s = s + k[i] - k[i - 1]
print(s)


from itertools import groupby, zip_longest

def grouper(iterable, n, fillvalue=None):
	args = [iter(iterable)] * n
	return zip_longest(*args, fillvalue=fillvalue)
n = int(input())
a = sorted(map(int, input().split()))
a = [k for (k, g) in groupby(a) if len(list(g)) % 2 == 1]
print(sum((p - o for (o, p) in grouper(a, 2))))


n = int(input())
a = sorted([int(x) for x in input().split()])
alpha = 0
for i in range(0, n - 1, 2):
	alpha += abs(a[i] - a[i + 1])
print(alpha)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
ans = 0
for i in range(0, n, 2):
	ans += arr[i + 1] - arr[i]
print(ans)


def mi():
	return list(map(int, input().split()))
n = int(input())
a = list(mi())
a.sort()
s = 0
for i in range(n):
	if i % 2:
		continue
	s += abs(a[i + 1] - a[i])
print(s)


n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(0, n, 2):
	count = count + l[i + 1] - l[i]
print(count)


n = int(input())
inp = input().split()
arr = []
for i in range(n):
	arr.append(int(inp[i]))
sum = 0
arr.sort()
for i in range(0, n - 1, 2):
	sum += arr[i + 1] - arr[i]
print(sum)


n = int(input())
m = sorted(list(map(int, input().split())))
c = 0
for i in range(n):
	if i % 2 == 0:
		c += abs(m[i + 1] - m[i])
print(c)


t = int(input())
arr = list(map(int, input().split()))
arr.sort()
r = 0
for i in range(0, len(arr) - 1, 2):
	x = abs(arr[i] - arr[i + 1])
	r += x
print(r)


import sys
import bisect
from random import randint
input = lambda : sys.stdin.readline().strip('\r\n')
from math import gcd
sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7

def hnbhai():
	n = sb()
	a = sd()
	a.sort()
	ans = 0
	for i in range(1, n, 2):
		ans += a[i] - a[i - 1]
	print(ans)
for _ in range(1):
	hnbhai()


n = int(input())
x = list(map(int, input().split()))
x.sort()
s = 0
i = 0
while i < n:
	s += x[i + 1] - x[i]
	i += 2
print(s)


input()
ar = list(map(int, input().split()))
ar.sort()
ans = 0
for i in range(0, len(ar), 2):
	ans += ar[i + 1] - ar[i]
print(ans)


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
s.sort()
ans = 0
for i in range(0, n, 2):
	ans += s[i + 1] - s[i]
print(ans)


n = int(input())
s = [int(i) for i in input().split()]
s.sort()
x = 0
for i in range(0, n, 2):
	x += abs(s[i] - s[i + 1])
print(x)


num = int(input())
li = list(map(int, input().split()))
li.sort()
a = 0
for i in range(0, num, 2):
	a += abs(li[i] - li[i + 1])
print(a)


from collections import Counter
n = int(input())
cnt = Counter(list(map(int, input().split())))
for v in cnt:
	if cnt[v] % 2 == 0:
		cnt[v] = 0
cnt += Counter()
lst = list(sorted(cnt))
ans = 0
for i in range(0, len(lst) - 1, 2):
	ans += lst[i + 1] - lst[i]
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = 0
for i in range(n - 1):
	if i % 2:
		continue
	else:
		ans += abs(a[i] - a[i + 1])
print(ans)


import math
import os
import random
import re
import sys
n = input().strip()
list1 = []
list1 = list(map(int, input().strip().split()))
b = sorted(list1)
cnt = 0
i = 1
while i < len(b):
	cnt = cnt + (b[i] - b[i - 1])
	i = i + 2
print(cnt)


n = int(input())
arr = list(map(int, input().split()))

def insertionSort(n, arr):
	for index in range(n):
		currentvalue = arr[index]
		position = index
		while position > 0 and arr[position - 1] > currentvalue:
			arr[position] = arr[position - 1]
			position = position - 1
			arr[position] = currentvalue

def counting(n, arr):
	if n == 2:
		return abs(arr[0] - arr[1])
	else:
		insertionSort(n, arr)
		new_list = []
		for i in range(1, n, 2):
			new_list.append(abs(arr[i] - arr[i - 1]))
		return sum(new_list)
ans = counting(n, arr)
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
b = []
a.sort()
m = a[0]
k = 0
for i in range(n):
	if m == a[i]:
		k += 1
	else:
		if k % 2 == 1:
			b.append(m)
		m = a[i]
		k = 1
if k % 2 == 1:
	b.append(m)
k = 0
for i in range(0, len(b), 2):
	k += b[i + 1] - b[i]
print(k)


n = input()
x = list(map(int, input().split()))
x.sort()
ans = 0
for i in range(1, len(x), 2):
	ans += int(x[i]) - int(x[i - 1])
print(ans)


def solve():
	n = int(input())
	A = [int(k) for k in input().split()]
	A.sort()
	ans = 0
	for i in range(0, n, 2):
		ans += A[i + 1] - A[i]
	print(ans)
solve()


input()
l = list(map(int, input().split()))
total = 0
dic = {}
for i in range(len(l)):
	for j in range(i + 1, len(l)):
		if l[j] > l[i]:
			temp = l[j]
			l[j] = l[i]
			l[i] = temp
for i in range(0, len(l) - 1, 2):
	total += abs(l[i] - l[i + 1])
print(str(total))


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().split(' ')))
	ans = 0
	a.sort()
	for i in range(0, n - 1, 2):
		ans += abs(a[i] - a[i + 1])
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


def quickCLR(v, st, dr):
	if st < dr:
		poz = partition(v, st, dr)
		quickCLR(v, st, poz - 1)
		quickCLR(v, poz + 1, dr)

def partition(v, st, dr):
	piv = v[dr]
	i = st - 1
	for j in range(st, dr):
		if v[j] <= piv:
			i = i + 1
			temp = v[i]
			v[i] = v[j]
			v[j] = temp
	temp = v[i + 1]
	v[i + 1] = v[dr]
	v[dr] = temp
	return i + 1
n = input()
cmd = input()
v = cmd.split(' ')
for i in range(len(v)):
	v[i] = int(v[i])
quickCLR(v, 0, len(v) - 1)
rez = 0
for i in range(1, len(v), 2):
	rez += v[i] - v[i - 1]
print(rez)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 998244353

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return list(map(int, sys.stdin.readline().strip().split()))

def charIN():
	return sys.stdin.readline().strip().split()
t = [(-1, -1)] * 1000010

def create(a):
	nonlocal t, n
	for i in range(n, 2 * n):
		t[i] = (a[i - n], i - n)
	for i in range(n - 1, 0, -1):
		x = [t[2 * i], t[2 * i + 1]]
		x.sort(key=lambda x: x[0])
		t[i] = x[1]

def update(idx, value):
	nonlocal t, n
	idx = idx + n
	t[idx] = value
	while idx > 1:
		idx = idx // 2
		x = [t[2 * idx], t[2 * idx + 1]]
		x.sort(key=lambda x: x[0])
		t[idx] = x[1]

def dis(a, b, k):
	ans = 0
	for i in range(k):
		ans += abs(a[i] - b[i])
	return ans

def cal(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]
n = int(input())
l = list(numIN())
l.sort()
ans = 0
for i in range(1, n, 2):
	ans += l[i] - l[i - 1]
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
cntr = 0
i = 0
while i < len(a):
	cntr += abs(a[i] - a[i + 1])
	i += 2
print(cntr)


n = int(input())
A = list(map(int, input().split()))
A.sort()
ANS = 0
for i in range(n // 2):
	ANS += A[2 * i + 1] - A[2 * i]
print(ANS)


n = int(input())
a = sorted([int(i) for i in input().split()])
s = 0
for i in range(0, n, 2):
	s += abs(a[i + 1] - a[i])
print(s)


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


n = int(input())
x = list(map(int, input().split()))
l1 = []
l2 = []
x.sort()
for j in range(n):
	if int(j % 2) == 0:
		l1.append(x[j])
	else:
		l2.append(x[j])
print(sum(l2) - sum(l1))


n = int(input())
pupils = list(map(int, input().split()))
pupils.sort()
tasks = 0
for i in range(0, n, 2):
	tasks += pupils[i + 1] - pupils[i]
print(tasks)


t = int(input())
l1 = [int(i) for i in input().split()]
l1 = sorted(l1)
ans = 0
for x in range(0, t, 2):
	ans += l1[x + 1] - l1[x]
print(ans)


n = int(input())
goo = list(map(int, input().split()))
goo.sort()
ss = 0
for i in range(0, n, 2):
	ss += goo[i - 1] - goo[i]
	if i == n - 2:
		break
print(ss)


n = int(input())
r = input()
r = r.split()
for i in range(n):
	r[i] = int(r[i])
r.sort()
m = 0
i = 0
while i < n:
	m += int(r[i + 1]) - int(r[i])
	i += 2
print(m)


n = int(input())
s = [int(x) for x in input().split()]
G = sorted(s)
c = 0
for i in range(0, len(G), 2):
	c = c + abs(G[i + 1] - G[i])
print(c)


input()
l = sorted([int(i) for i in input().split(' ')])
print(sum([abs(l[i + 1] - l[i]) for i in range(0, len(l), 2)]))


le = int(input())
n = list(map(int, input().split()))
n = sorted(n)
end = 0
tmp = 1
for i in range(0, le - 1, 2):
	end += abs(n[i] - n[tmp])
	tmp += 2
print(end)


n1 = int(input())
s1 = list(map(int, input().split()))
s1.sort()
sa1 = 0
se2 = 0
for i in range(0, n1, 2):
	sa1 = sa1 + s1[i]
for i in range(1, n1, 2):
	se2 = se2 + s1[i]
print(se2 - sa1)


n = int(input(''))
a = list(map(int, input('').strip().split()))[:n]
x = len(a)
count = 0
a.sort()
for i in range(0, x, 2):
	diff = a[i] - a[i + 1]
	count = count + abs(diff)
print(count)


def teams(n, ls):
	ls.sort()
	i = 0
	n = n - 1
	s = 0
	while i < n:
		s = s + (ls[i + 1] - ls[i])
		i = i + 2
	return s
n = int(input())
ls = [int(i) for i in input().split()]
print(teams(n, ls))


n = int(input())
l = list(map(int, input().split()))
l.sort()
no = 0
i = 0
while i < n:
	no = no + l[i + 1] - l[i]
	i = i + 2
print(no)


n = int(input())
arr = list(map(int, input().split(' ')))
l = sorted(arr)
sub = 0
for i in range(1, n, 2):
	sub += l[i] - l[i - 1]
print(sub)


n = int(input())
b = [int(a) for a in input().split(' ')]
s_b = sorted(b)
result = 0
for i in range(0, len(s_b) - 1, 2):
	result = result + (s_b[i + 1] - s_b[i])
print(result)


n = int(input())
list1 = input().split(' ')
list1 = [int(x) for x in list1]
list1.sort()
sum1 = sum([abs(list1[x] - list1[x + 1]) for x in range(0, n, 2)])
print(sum1)


n = int(input())
numbers = [int(i) for i in input().split()]
numbers.sort()
questions = 0
for i in range(0, n, 2):
	questions += numbers[i + 1] - numbers[i]
print(questions)


n = eval(input())
line = input()
strings = line.split()
list = []
for string in strings:
	list.append(eval(string))
sortedList = sorted(list)
size = len(list)
pn = 0
for k in range(0, size, 2):
	pn += abs(sortedList[k] - sortedList[k + 1])
print(pn)


import sys
n = int(input())
b = list(map(int, input().split()))
b.sort()
l = len(b)
result = 0
for i in range(0, l - 1, 2):
	result = result + b[i + 1] - b[i]
print(result)


i = int(input())
x = list(map(int, input().split()))
x.sort()
c = 0
for s in range(i // 2):
	c = c + x[2 * s + 1] - x[2 * s]
print(c)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
l.sort()
count = 0
for i in range(0, n, 2):
	count += abs(l[i] - l[i + 1])
print(count)


n = int(input())
m = [int(s) for s in input().split()]
count = 0
for i in range(n // 2):
	a = min(m)
	m.remove(a)
	b = min(m)
	count += abs(a - b)
	m.remove(b)
print(count)


n = int(input())
k = n // 2
L = [int(x) for x in input().split()]
L.sort()
s = 0
for i in range(0, k):
	s += L[2 * i + 1] - L[2 * i]
print(s)


import math
for _ in range(1):
	n = int(input())
	l1 = list(map(int, input().split()))
	l1.sort()
	c = 0
	for i in range(0, n - 1, 2):
		c = c + abs(l1[i] - l1[i + 1])
	print(c)


n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()
result = 0
for i in range(0, n, 2):
	result += numbers[i + 1] - numbers[i]
print(result)


n = int(input())
s = [int(i) for i in input().split()]
s.sort()
t = 0
for i in range(0, n, 2):
	t += s[i + 1] - s[i]
print(t)


num = int(input())
students = input().split(' ')
students = [int(i) for i in students]
students.sort()
answer = 0
for i in range(num // 2):
	answer += students[i * 2 + 1] - students[i * 2]
print(answer)


n = input()
cmd = input()
v = cmd.split(' ')
for i in range(len(v)):
	v[i] = int(v[i])
v = sorted(v)
rez = 0
for i in range(1, len(v), 2):
	rez += v[i] - v[i - 1]
print(rez)


t = int(input())
a = [int(i) for i in input().split()]
a.sort()
s = 0
for i in range(0, len(a), 2):
	s += a[i + 1] - a[i]
print(s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
arr = list(map(int, input().split()))
ans = 0
arr.sort()
for i in range(n // 2):
	ans += arr[2 * i + 1] - arr[2 * i]
print(ans)


n = int(input())
a = [int(j) for j in input().split()]
a.sort(reverse=True)
if n % 2 == 0:
	ans = 0
	for i in range(0, n):
		if i % 2 == 0:
			ans += abs(a[i] - a[i + 1])
	print(ans)
else:
	ans1 = 0
	ans2 = 0
	for i in range(0, n):
		if i % 2 != 0:
			ans1 += abs(a[i] - a[i + 1])
	for i in range(0, n):
		if i % 2 == 0 and i != n - 1:
			ans2 += abs(a[i] - a[i + 1])
	print(min(ans1, ans2))


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
ans = 0
l.sort()
for k in range(0, n, 2):
	ans += l[k + 1] - l[k]
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n // 2):
	ans += a[2 * i + 1] - a[2 * i]
print(ans)


numOfStudents = int(input())
students = input().split()
student = int(students[0])
tasksNeed = 0
for i in range(numOfStudents, 0, -1):
	for j in range(1, i):
		if int(students[j - 1]) > int(students[j]):
			tmp = students[j - 1]
			students[j - 1] = students[j]
			students[j] = tmp
for i in range(0, numOfStudents - 1, 2):
	if int(students[i]) != int(students[i + 1]):
		minNumber = min(int(students[i]), int(students[i + 1]))
		maxNumber = max(int(students[i]), int(students[i + 1]))
		while minNumber != maxNumber:
			minNumber += 1
			tasksNeed += 1
print(tasksNeed)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s1 = 0
s2 = 0
for i in range(0, n, 2):
	s1 += l[i]
for i in range(1, n, 2):
	s2 += l[i]
print(s2 - s1)


def merge(left, right):
	res = []
	while True:
		if not left and (not right):
			break
		if not left:
			res = res + right
			right = []
		if not right:
			res = res + left
			left = []
		if left and right:
			if left[0] > right[0]:
				res.append(right.pop(0))
			else:
				res.append(left.pop(0))
	return res

def merge_sort(arr, n):
	if n == 1:
		return arr
	nmid = n // 2
	left = arr[:nmid]
	right = arr[nmid:]
	left = merge_sort(left, len(left))
	right = merge_sort(right, len(right))
	return merge(left, right)

def fun1(a, n):
	asorted = merge_sort(a, n)
	count = sum([abs(asorted[i] - asorted[i + 1]) for i in range(0, len(asorted), 2)])
	return count

def sol():
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	print(fun1(a, n))

def mytest(arr, n, ans):
	myans = fun1(arr, n)
	print(ans == myans)
sol()


n = int(input())
a = sorted(map(int, input().split()))
sum = 0
for i in range(0, n, 2):
	sum = sum + abs(a[i] - a[i + 1])
print(sum)


n = eval(input())
skill = input()
skill = list(map(int, skill.strip().split()))
exercise = 0
for i in range(len(skill) - 1):
	for j in range(i + 1, len(skill)):
		if skill[i] > skill[j]:
			(skill[i], skill[j]) = (skill[j], skill[i])
for i in range(0, len(skill), 2):
	if not skill[i] == skill[i + 1]:
		exercise += abs(skill[i] - skill[i + 1])
print(exercise)


import math
t = int(input())
inputs = []
temp = input().split()
for i in range(t):
	inputs.append(int(temp[i]))
inputs.sort()
sum = 0
for i in range(math.ceil(t / 2)):
	sum += inputs[2 * i + 1] - inputs[2 * i]
print(sum)


input()
l = list(map(int, input().split()))
l.sort()
n = 0
for x in range(len(l) // 2):
	n += l[x * 2 + 1] - l[x * 2]
print(n)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for i in range(0, len(l), 2):
	ans += l[i] - l[i + 1]
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
s = 0
for i in range(n - 1):
	x = i + 1
	for j in range(i + 1, n):
		if abs(a[x] - a[i]) > abs(a[j] - a[i]) and a[j] != -1 and (a[i] != -1):
			x = j
	if a[x] != -1 and a[i] != -1:
		s += abs(a[x] - a[i])
		a[x] = -1
print(s)


def ii():
	return int(input())

def mi():
	return list(map(int, input().split()))

def li():
	return list(mi())
n = ii()
a = li()
a.sort()
ans = sum((a[i + 1] - a[i] for i in range(0, n, 2)))
print(ans)


n = int(input())
teams = [int(x) for x in input().split()]
teams = sorted(teams)
count = 0
for i in range(0, n, 2):
	count += teams[i + 1] - teams[i]
print(count)


def mergeSort(v):
	if len(v) == 0:
		return []
	elif len(v) == 1:
		return [v[0]]
	else:
		mij = len(v) // 2
		left = mergeSort(v[:mij])
		right = mergeSort(v[mij:])
		return merge(left, right)

def merge(l, r):
	pozl = 0
	pozr = 0
	rez = []
	while pozl < len(l) and pozr < len(r):
		if l[pozl] < r[pozr]:
			rez.append(l[pozl])
			pozl += 1
		else:
			rez.append(r[pozr])
			pozr += 1
	while pozl < len(l):
		rez.append(l[pozl])
		pozl += 1
	while pozr < len(r):
		rez.append(r[pozr])
		pozr += 1
	return rez
n = input()
cmd = input()
v = cmd.split(' ')
for i in range(len(v)):
	v[i] = int(v[i])
v = mergeSort(v)
rez = 0
for i in range(1, len(v), 2):
	rez += v[i] - v[i - 1]
print(rez)


def closest(lst, K):
	return lst[min(range(len(lst)), key=lambda i: abs(lst[i] - K))]

def int_put():
	num_list = input('').split()
	return [int(input) for input in num_list]
st_num = int(input(''))
skill_list = int_put()
skill_list.sort()
ex_num = 0

def find_ex_num(skill_li):
	global ex_num
	if len(skill_li) == 0:
		return
	curr_skill = skill_li[0]
	skill_li.remove(curr_skill)
	closest_num = closest(skill_li, curr_skill)
	skill_li.remove(closest_num)
	if closest_num == curr_skill:
		return find_ex_num(skill_li)
	else:
		ex_num += abs(closest_num - curr_skill)
		return find_ex_num(skill_li)
find_ex_num(skill_list)
print(ex_num)


def main():
	n_students = int(input())
	skills = [int(x) for x in input().split()]
	skills.sort()
	n_problems = sum((skills[i + 1] - skills[i] for i in range(0, n_students, 2)))
	print(n_problems)
main()


n = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[1::2]) - sum(A[0::2]))


(n, c) = (int(input()), 0)
ns = sorted(list(map(int, input().split())))
print(sum((ns[i + 1] - ns[i] for i in range(0, n, 2))))


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	A = read_ints()
	G = Counter(A)
	B = []
	for (k, v) in G.items():
		if v % 2 == 1:
			B.append(k)
	B.sort()
	ans = 0
	for i in range(1, len(B), 2):
		ans += B[i] - B[i - 1]
	print(ans)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
l = list(map(int, input().split()))
sub = 0
l.sort()
li = []
for i in range(0, n, 2):
	sub = l[i + 1] - l[i]
	li.append(sub)
print(sum(li))


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(0, n, 2):
	ans += abs(l[i] - l[i + 1])
print(ans)


n = int(input())
a = list(map(int, input().split()))
k = 0
a.sort(reverse=True)
for i in range(0, n, 2):
	k += a[i] - a[i + 1]
print(k)


n = int(input())
answ = 0
students = sorted(list(map(int, input().split())))
for i in range(0, len(students), 2):
	answ += students[i + 1] - students[i]
print(answ)


n = int(input())
x = [int(x) for x in input().split()]
x.sort()
s = 0
if n == 2:
	print(abs(x[0] - x[1]))
	exit()
else:
	for i in range(0, n, 2):
		s = s + abs(x[i] - x[i + 1])
print(s)


n = int(input())
k = list(map(int, input().split()))
k = sorted(k)
s = 0
j = 1
for i in range(1, n):
	if j > n:
		break
	else:
		s += k[j] - k[j - 1]
		j += 2
print(s)


N = int(input())
skills = sorted(list(map(int, input().strip().split())))
ans = 0
for i in range(N // 2):
	ans += skills[2 * i + 1] - skills[2 * i]
print(ans)


n = int(input())
l = list(map(int, input().split()))
counter = 0
for j in l:
	if l.count(j) == 2:
		l.remove(j)
		l.remove(j)
l = sorted(l)
for i in range(0, len(l) - 1, 2):
	while l[i] != l[i + 1]:
		l[i] = l[i] + 1
		counter += 1
print(counter)


n = int(input())
students = sorted(map(int, input().split()))
ans = 0
for i in range(0, len(students) - 1, 2):
	ans += abs(students[i] - students[i + 1])
print(ans)


improvement = 0
n = int(input())
arr = []
for i in map(int, input().split()):
	arr.append(i)
arr = sorted(arr)
if len(arr) == 2:
	print(abs(arr[0] - arr[1]))
else:
	for j in range(1, n, 2):
		improvement += abs(arr[j] - arr[j - 1])
	print(improvement)


n = int(input())
a = sorted(list(map(int, input().split())))
answer = 0
for q in range(0, n, 2):
	answer += a[q + 1] - a[q]
print(answer)


n = int(input())
arr = sorted(list(map(int, input().split())))
points = 0
for i in range(0, n, 2):
	points += arr[i + 1] - arr[i]
print(points)


inp1 = int(input())
inp2 = sorted(map(int, input().split()))
num = int()
for x in range(0, inp1, 2):
	num = num + abs(inp2[x] - inp2[x + 1])
print(num)


import os, sys

def find_min():
	n_st = input()
	st_skills = input().split()
	st_skills_int = []
	for each in st_skills:
		each = int(each)
		st_skills_int.append(each)
	i = 0
	min_total = 0
	st_skills_int.sort()
	while i < len(st_skills_int) - 1:
		min_total = min_total + abs(st_skills_int[i] - st_skills_int[i + 1])
		i = i + 2
	print(min_total)
find_min()


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


n = int(input())
l = [int(n) for n in input().split()]
l = sorted(l)
ct = 0
for i in range(1, n, 2):
	ct += l[i] - l[i - 1]
print(ct)


def swap(z, x, y):
	temp = z[x]
	z[x] = z[y]
	z[y] = temp
n = input()
n = int(n)
a = input().split()
for k in range(n):
	a[k] = int(a[k])
b = len(a)
for i in range(b):
	temp = i
	for j in range(i, b):
		if a[temp] > a[j]:
			temp = j
	if temp != i:
		swap(a, temp, i)
flag = 0
for i in range(0, n - 1, 2):
	d = a[i + 1] - a[i]
	flag = flag + d
print(flag)


n = int(input())
a = [int(i) for i in input().split()]
k = 0
f1 = 0
f2 = 0
for i in range(n // 2):
	f1 = min(a)
	a.remove(min(a))
	f2 = min(a)
	a.remove(min(a))
	k += f2 - f1
	f1 = 0
	f2 = 0
print(k)


import sys

def teams(skills):
	skills = sorted(skills)
	output2 = 0
	for i in range(0, len(skills), 2):
		dif = skills[i + 1] - skills[i]
		output2 += dif
	print(output2)
	pass

def main():
	n = int(sys.stdin.readline())
	arr = map(int, sys.stdin.readline().split())
	teams(arr)
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
problems = 0
for i in range(0, len(a), 2):
	problems += a[i + 1] - a[i]
print(problems)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = ria()
		a = sorted(a)
		s = 0
		for i in range(1, n, 2):
			s += a[i] - a[i - 1]
		wi(s)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
count = 0
for i in range(0, len(arr) - 1, 2):
	count += abs(arr[i + 1] - arr[i])
print(count)


n = int(input())
A = input().split(' ')
A.sort(key=int)
ans = 0
for i in range(0, len(A), 2):
	ans = ans + int(A[i + 1]) - int(A[i])
print(ans)