import java.util.*;

public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

} import java.util.*; util.* java public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int rimit = sc.nextInt(); rimit sc.nextInt() sc.nextInt sc List<Integer> numList = new ArrayList<Integer>(); numList new ArrayList<Integer>() for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    } int num = 1; int num = 1; num 1 num<=rimit num rimit num++ num++ num {
      numList.add(sc.nextInt());
    } {
      numList.add(sc.nextInt());
    } numList.add(sc.nextInt()) numList.add numList sc.nextInt() sc.nextInt sc int ans = 0; ans 0 int turn = 2; turn 2 Collections.sort(numList, Collections.reverseOrder()) Collections.sort Collections numList Collections.reverseOrder() Collections.reverseOrder Collections for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    } int num numList {
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    } {
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    } if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      } turn % 2 == 0 turn % 2 turn 2 0 {
        ans += num;
      } ans += num ans num {
        ans -= num;
      } ans -= num ans num turn++ turn 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){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

} public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

} Main
import java.util.*;

public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

}