import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    } main {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int givenNumber = scanner.nextInt(); givenNumber scanner.nextInt() scanner.nextInt scanner int[] array = new int[givenNumber]; array new int[givenNumber] givenNumber for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        } int i=0; int i=0; i 0 i<givenNumber i givenNumber i++ i++ i {
            array[i] = scanner.nextInt();
        } {
            array[i] = scanner.nextInt();
        } array[i] = scanner.nextInt() array[i] array i scanner.nextInt() scanner.nextInt scanner Arrays.sort(array) Arrays.sort Arrays array int aliceCards = 0; aliceCards 0 int bobCards = 0; bobCards 0 for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        } int i=0; int i=0; i 0 i<array.length i array.length array array.length i++ i++ i {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        } {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        } if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            } i % 2 == 0 i % 2 i 2 0 {
                bobCards += array[i];
            } bobCards += array[i] bobCards array[i] array i {
                aliceCards += array[i];
            } aliceCards += array[i] aliceCards array[i] array i System.out.println(Math.abs(aliceCards - bobCards)) System.out.println System.out System System.out Math.abs(aliceCards - bobCards) Math.abs Math aliceCards - bobCards aliceCards bobCards String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
        int aliceCards = 0;
        int bobCards = 0;
        for(int i=0; i<array.length; i++) {
            if(i % 2 == 0) {
                bobCards += array[i];
            } else {
                aliceCards += array[i];
            }
        }
        System.out.println(Math.abs(aliceCards - bobCards));
    }
}
