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