import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    } main {
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n int x = 0; x 0 int y = 0; y 0 for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        a[i] = sc.nextInt();
        y += a[i];
      } {
        a[i] = sc.nextInt();
        y += a[i];
      } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc y += a[i] y a[i] a i Arrays.sort(a) Arrays.sort Arrays a for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      } int i = n-1; int i = n-1; i n-1 n 1 i>=0 i 0 i -= 2 i -= 2 i 2 {
      	x += a[i];
      } {
      	x += a[i];
      } x += a[i] x a[i] a i System.out.println(x*2-y) System.out.println System.out System System.out x*2-y x*2 x 2 y String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int x = 0;
      int y = 0;
      for(int i = 0;i < n;i++){
        a[i] = sc.nextInt();
        y += a[i];
      }
      Arrays.sort(a);
      for(int i = n-1;i>=0;i -= 2){
      	x += a[i];
      }
      System.out.println(x*2-y);
    }
}