import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  } main {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int[] val = new int[N]; val new int[N] N for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      val[i] = Integer.parseInt(sc.next());
    } {
      val[i] = Integer.parseInt(sc.next());
    } val[i] = Integer.parseInt(sc.next()) val[i] val i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(val) Arrays.sort Arrays val int a = 0; a 0 int b = 0; b 0 for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    } {
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    } if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      } i%2==0 i%2 i 2 0 {
        a += val[i];
      } a += val[i] a val[i] val i {
        b += val[i];
      } b += val[i] b val[i] val i System.out.println(Math.abs(a-b)) System.out.println System.out System System.out Math.abs(a-b) Math.abs Math a-b a b String[]args args public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
}