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