import java.util.Arrays;
import java.util.Scanner;
     
    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 A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      }
    } import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner 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 A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      }
    } Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int []a = new int[N];
        
        int A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int []a = new int[N];
        
        int A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      } 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 A = 0; A 0 int B = 0; B 0 for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        	 a[i] = sc.nextInt();
        } {
        	 a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        } {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        } if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	} i%2 != 0 i%2 i 2 0 {
        		A += a[i];
        	} A += a[i] A a[i] a i {
        		B += a[i];
        	} B += a[i] B a[i] a i System.out.println(Math.abs(A-B)) System.out.println System.out System System.out Math.abs(A-B) Math.abs Math A-B A B 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 A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      }
    } 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 A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      }
    } Main
import java.util.Arrays;
import java.util.Scanner;
     
    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 A = 0;
        int B = 0;
        for(int i=0; i<N; i++) {
        	 a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++) {
        	if(i%2 != 0) {
        		A += a[i];
        	}else {
        		B += a[i];
        	}
        }
        System.out.println(Math.abs(A-B));
      }
    }