#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 7;
bool arr[N];
int n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int act;
    cin >> act;
    arr[act] ^= 1;
  }
  int res = 0;
  int lst = -1;
  for (int i = 0; i < 101; ++i) {
    if (arr[i]) {
      if (lst == -1) {
        lst = i;
      } else {
        res += i - lst;
        lst = -1;
      }
    }
  }
  cout << res << "\n";
  return 0;
}
