import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt() A sc.nextInt() sc.nextInt sc ans1 = 0 ans1 0 ans2 = 0; ans2 0 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < A i A i++ i++ i {
            list.add(sc.nextInt());
        } {
            list.add(sc.nextInt());
        } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Collections.sort(list) Collections.sort Collections list if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        } A % 2 == 0 A % 2 A 2 0 {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        } while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            } A >= 1 A 1 {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            } ans1 += list.get(A - 1) ans1 list.get(A - 1) list.get list A - 1 A 1 ans2 += list.get(A - 2) ans2 list.get(A - 2) list.get list A - 2 A 2 A -= 2 A 2 {
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        } while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            } A >= 0 A 0 {
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            } ans1 += list.get(A-1) ans1 list.get(A-1) list.get list A-1 A 1 if(A == 1){
                    break;
                } A == 1 A 1 {
                    break;
                } break; ans2 += list.get(A-2) ans2 list.get(A-2) list.get list A-2 A 2 A -= 2 A 2 System.out.println(ans1-ans2) System.out.println System.out System System.out ans1-ans2 ans1 ans2 String[] args args
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),ans1 = 0,ans2 = 0;
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < A; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        if(A % 2 == 0) {
            while (A >= 1) {
                ans1 += list.get(A - 1);
                ans2 += list.get(A - 2);
                A -= 2;
            }
        }else{
            while(A >= 0){
                ans1 += list.get(A-1);
                if(A == 1){
                    break;
                }
                ans2 += list.get(A-2);
                A -= 2;
            }
        }
        System.out.println(ans1-ans2);
    }
}
