#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, mp = 0;
  cin >> n;
  long long arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i += 2) {
    mp += arr[i + 1] - arr[i];
  }
  cout << mp;
  return 0;
}
