#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return x == 0 ? y : gcd(y % x, x); }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int main() {
  int t, n, k, a[1001];
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 2; i <= n; i += 2) {
    ans += abs(a[i] - a[i - 1]);
  }
  cout << ans;
  return 0;
}
