import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//  B - Card Game for Two

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

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  }
}
 import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args ) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  }
} Main public static void main(String[] args ) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  } main {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List<Integer> list = new ArrayList(); list new ArrayList() for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    	list.add(Integer.parseInt(sc.next()));
    } {
    	list.add(Integer.parseInt(sc.next()));
    } list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int alice = 0; alice 0 int bob = 0; bob 0 boolean flg = true; flg true Collections.sort(list) Collections.sort Collections list Collections.reverse(list) Collections.reverse Collections list for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    } Integer a list {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    } {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    } if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	} flg {
    		alice += a;
    		flg = false;
    	} alice += a alice a flg = false flg false {
    		bob += a;
    		flg = true;
    	} bob += a bob a flg = true flg true 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 ) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  }
} public class Main {
  public static void main(String[] args ) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//  B - Card Game for Two

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

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < n ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    int alice = 0;
    int bob = 0;

    boolean flg = true;
    Collections.sort(list);
    Collections.reverse(list);
    for(Integer a : list) {
    	if(flg) {
    		alice += a;
    		flg = false;
    	} else {
    		bob += a;
    		flg = true;
    	}
    }

    	System.out.println(alice-bob);
  }
}

