#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,e=0,f=0,j,i;
cin>>a;
vector<ll>v;
for(i=1;i<=a;i++)
{
cin>>b;v.push_back(b);
}
sort(v.begin(),v.end());
for(i=a-1,j=1;i>=0;i--,j++)
{
if(j%2==1)e+=v[i];
else f+=v[i];
}
    cout<<e-f<<endl;
}