import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    }
} import java.lang.reflect.Array; Array java.lang.reflect import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int []a = new int [n]; a new int [n] n for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            a[i] = s.nextInt();
        } {
            a[i] = s.nextInt();
        } a[i] = s.nextInt() a[i] a i s.nextInt() s.nextInt s Arrays.sort(a) Arrays.sort Arrays a int cnt1 = 0 cnt1 0 cnt2 = 0; cnt2 0 boolean al = true; al true for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 --i --i i {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        } {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        } if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            } al {
                al = false;
                cnt1 += a[i];
            } al = false al false cnt1 += a[i] cnt1 a[i] a i {
                al = true;
                cnt2 += a[i];
            } al = true al true cnt2 += a[i] cnt2 a[i] a i System.out.println(cnt1 - cnt2) System.out.println System.out System System.out cnt1 - cnt2 cnt1 cnt2 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    }
} Main
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int []a = new int [n];
        for(int i = 0; i < n; ++i) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int cnt1 = 0,cnt2 = 0;
        boolean al = true;
        for(int i = n - 1; i >= 0; --i) {
            if(al) {
                al = false;
                cnt1 += a[i];
            }
            else {
                al = true;
                cnt2 += a[i];
            }
        }
        System.out.println(cnt1 - cnt2);
    }
}
