
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    }

} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    }

} Main public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    } main {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    } Scanner Input = new Scanner(System.in); Input new Scanner(System.in) int N = Input.nextInt(); N Input.nextInt() Input.nextInt Input ArrayList<Integer> A = new ArrayList(); A new ArrayList() for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        } int I = 0; int I = 0; I 0 I < N I N I++ I++ I {
            A.add(Input.nextInt());
        } {
            A.add(Input.nextInt());
        } A.add(Input.nextInt()) A.add A Input.nextInt() Input.nextInt Input Collections.sort(A, Collections.reverseOrder()) Collections.sort Collections A Collections.reverseOrder() Collections.reverseOrder Collections int Sum = 0; Sum 0 for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        } int I = 0; int I = 0; I 0 I < A.size() I A.size() A.size A I++ I++ I {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        } {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        } if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            } I % 2 == 0 I % 2 I 2 0 {
                Sum += A.get(I);
            } Sum += A.get(I) Sum A.get(I) A.get A I {
                Sum -= A.get(I);
            } Sum -= A.get(I) Sum A.get(I) A.get A 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) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    }

} public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    }

} Main

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        ArrayList<Integer> A = new ArrayList();
        for (int I = 0; I < N; I++) {
            A.add(Input.nextInt());
        }
        Collections.sort(A, Collections.reverseOrder());
        int Sum = 0;
        for (int I = 0; I < A.size(); I++) {
            if (I % 2 == 0) {
                Sum += A.get(I);
            } else {
                Sum -= A.get(I);
            }
        }
        System.out.println(Sum);
    }

}
