#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
string s;
long long n, m, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  sort(a.begin() + 1, a.end());
  reverse(a.begin() + 1, a.end());
  for (int i = 2; i <= n; i += 2) m += a[i - 1] - a[i];
  cout << m;
}
