import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
} Main public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s Integer l[] = new Integer[n]; l new Integer[n] n for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        } int i = 0; int i = 0; i 0 i < l.length i l.length l l.length i++ i++ i {
            l[i] = s.nextInt();
        } {
            l[i] = s.nextInt();
        } l[i] = s.nextInt() l[i] l i s.nextInt() s.nextInt s Arrays.sort(l, Collections.reverseOrder()) Arrays.sort Arrays l Collections.reverseOrder() Collections.reverseOrder Collections int sum = 0; sum 0 for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        } int i = 0; int i = 0; i 0 i < l.length i l.length l l.length i++ i++ i {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        } {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        } if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            } i % 2 == 0 i % 2 i 2 0 {
                sum = sum + l[i];
            } sum = sum + l[i] sum sum + l[i] sum l[i] l i {
                sum = sum - l[i];
            } sum = sum - l[i] sum sum - l[i] sum l[i] l i System.out.println(sum) System.out.println System.out System System.out sum String args[] args public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
} Main
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
}