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