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