#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int sum,n,a[105];
bool cmp(int x,int y){return x>y;}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n,cmp);
	for(int i=0;i<n;i+=2){
		sum+=a[i]-a[i+1];
	}
	cout<<sum<<endl;
	return 0;
}