import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  }
} Main public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  } main {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int N; N int Alice = 0; Alice 0 int Bob = 0; Bob 0 ArrayList<Integer> L = new ArrayList<Integer>(); L new ArrayList<Integer>() N = s.nextInt() N s.nextInt() s.nextInt s for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      L.add(s.nextInt());
    } {
      L.add(s.nextInt());
    } L.add(s.nextInt()) L.add L s.nextInt() s.nextInt s Collections.sort(L) Collections.sort Collections L for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    } int i = 0; int i = 0; i 0 i < N i N i += 2 i += 2 i 2 {
      Alice += L.get(i);
    } {
      Alice += L.get(i);
    } Alice += L.get(i) Alice L.get(i) L.get L i for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    } int i = 1; int i = 1; i 1 i < N i N i += 2 i += 2 i 2 {
      Bob += L.get(i);
    } {
      Bob += L.get(i);
    } Bob += L.get(i) Bob L.get(i) L.get L i System.out.printf("%d",Math.abs(Alice - Bob)) System.out.printf System.out System System.out "%d" Math.abs(Alice - Bob) Math.abs Math Alice - Bob Alice Bob String[] args args public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int Alice = 0;
    int Bob = 0;
    ArrayList<Integer> L = new ArrayList<Integer>();
    N = s.nextInt();
    for(int i = 0; i < N ;i++){
      L.add(s.nextInt());
    }
    Collections.sort(L);
    for(int i = 0; i < N ;i += 2){
      Alice += L.get(i);
    }
    for(int i = 1; i < N ;i += 2){
      Bob += L.get(i);
    }
    System.out.printf("%d",Math.abs(Alice - Bob));
  }
}
