#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(100);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=0;
  sort(a.begin(),a.end(),greater<int>());
  for (int i=0;i<n;i+=2){
    ans+=a[i]-a[i+1];
  }
  cout << ans << endl;
}