#include <bits/stdc++.h>
using namespace std;
const double h = 1e-6;
const int MAX_ = 100005;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > 1000000007) c -= 1000000007;
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    ans += (abs(arr[i] - arr[i + 1]));
  }
  cout << ans;
  return 0;
}
