import java.util.*;


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

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    }
} Main public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    } main {

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int cards = s.nextInt(); cards s.nextInt() s.nextInt s ArrayList<Integer> card = new ArrayList<Integer>(); card new ArrayList<Integer>() for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        } int i = 0; int i = 0; i 0 i < cards i cards i++ i++ i {
          card.add(s.nextInt());
        } {
          card.add(s.nextInt());
        } card.add(s.nextInt()) card.add card s.nextInt() s.nextInt s Collections.sort(card, Comparator.reverseOrder()) Collections.sort Collections card Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        } int i = 0; int i = 0; i 0 i < cards i cards i++ i++ i {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        } {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        } if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          } i%2 == 0 i%2 i 2 0 {
            alice = alice + card.get(i);
          } alice = alice + card.get(i) alice alice + card.get(i) alice card.get(i) card.get card i {
            bob = bob + card.get(i);
          } bob = bob + card.get(i) bob bob + card.get(i) bob card.get(i) card.get card i System.out.println(alice-bob) System.out.println System.out System System.out alice-bob alice bob String[] args args public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    }
} public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    }
} Main
import java.util.*;


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

        Scanner s = new Scanner(System.in);
        int cards = s.nextInt();
        ArrayList<Integer> card = new ArrayList<Integer>();

        for (int i = 0; i < cards; i++) {
          card.add(s.nextInt());
        }

        // 降順
        Collections.sort(card, Comparator.reverseOrder()); 

        int alice = 0;
        int bob = 0;

        for (int i = 0; i < cards; i++) {
          if(i%2 == 0) {
            alice = alice + card.get(i);
          } else {
            bob = bob + card.get(i);
          }
        }
        System.out.println(alice-bob);
    }
}