import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> li = new ArrayList<>(); li new ArrayList<>() for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            li.add(sc.nextInt());
        } {
            li.add(sc.nextInt());
        } li.add(sc.nextInt()) li.add li sc.nextInt() sc.nextInt sc Collections.sort(li, Comparator.reverseOrder()) Collections.sort Collections li Comparator.reverseOrder() Comparator.reverseOrder Comparator int ans = 0; ans 0 int i = 0; i 0 for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        } int a li {
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        } {
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        } if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            } i % 2 == 0 i % 2 i 2 0 {
                ans += a;
            } ans += a ans a {
                ans -= a;
            } ans -= a ans a i++ i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
}
