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

