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