#include <bits/stdc++.h>
using namespace std;
long long n, m, b, c, l, r, x, e, h, k, res1, a1, a2, w, a3, y, z, a4, a5, a6,
    a7, a8, a9, a10, last, LL, timer, start, finish, flag, step, tests, kilk;
string s, s1;
char t;
long long res;
vector<long long> a;
long long mas[200007];
priority_queue<long long> q;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> mas[i];
  }
  sort(mas + 1, mas + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      res += mas[i + 1] - mas[i];
    }
  }
  cout << res << endl;
}
