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