import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	} main {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	} int i; i Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc ArrayList<Integer> a = new ArrayList<>(); a new ArrayList<>() for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			a.add(Integer.parseInt(sc.next()));
		} {
			a.add(Integer.parseInt(sc.next()));
		} a.add(Integer.parseInt(sc.next())) a.add a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc Collections.sort(a, Comparator.reverseOrder()) Collections.sort Collections a Comparator.reverseOrder() Comparator.reverseOrder Comparator int ans = 0; ans 0 for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		} {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		} if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i); i%2==0 i%2 i 2 0 ans+=a.get(i) ans a.get(i) a.get a i ans-=a.get(i) ans a.get(i) a.get a i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> a = new ArrayList<>(); 
//		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(a, Comparator.reverseOrder());
		int ans = 0;
		for(i=0;i<n;i++) {
			if(i%2==0)ans+=a.get(i);
			     else ans-=a.get(i);
		}
		System.out.println(ans);
	}
}
