#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a[110];
  int sum = 0;
  cin >> N;
  for (int i=0; i<N; i++)
    cin >> a[i];
  a[N] = 0;
  sort(a, a+N, greater<int>());
  for (int i=0; i<N; i += 2)
    sum += a[i] - a[i+1];
  cout << sum;
}
