#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return (a) ? GCD(b % a, a) : b; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long fastpow(long long b, long long p) {
  if (!p) return 1;
  long long ret = fastpow(b, p >> 1);
  ret *= ret;
  if (p & 1) ret *= b;
  return ret;
}
int arr[101];
int main() {
  int n;
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int s = 0;
  for (size_t i = 1; i < n; i += 2) {
    s += (arr[i] - arr[i - 1]);
  }
  cout << s;
}
