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