#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n, cnt;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	freopen("group.in", "r", stdin);
	freopen("group.out", "w", stdout);
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for(int i = 1; i < n; i += 2)
		cnt += abs(a[i] - a[i + 1]);
	cout << cnt;
	return 0;
}

