import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int aa[] = new int[n]; aa new int[n] n for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
      aa[i] = sc.nextInt();
    } {
      aa[i] = sc.nextInt();
    } aa[i] = sc.nextInt() aa[i] aa i sc.nextInt() sc.nextInt sc Arrays.sort(aa) Arrays.sort Arrays aa int a = 0; a 0 int b = 0; b 0 int count = 0; count 0 for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    } int i = n-1; int i = n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    } {
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    } if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      } count % 2 == 0 count % 2 count 2 0 {
        a += aa[i];
      } a += aa[i] a aa[i] aa i {
        b += aa[i];
      } b += aa[i] b aa[i] aa i count++ count System.out.println(a-b) System.out.println System.out System System.out a-b a b String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int aa[] = new int[n];
    for(int i = 0;i<n;i++){
      aa[i] = sc.nextInt();
    }
    Arrays.sort(aa);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = n-1;i>=0;i--){
      if(count % 2 == 0){
        a += aa[i];
      }else{
        b += aa[i];
      }
      count++;
    }
    System.out.println(a-b);
  }
}
