import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io import java.util.Arrays; Arrays java.util public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(in.readLine()); n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int[] a = new int[n]; a new int[n] n int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
      a[i] = Integer.parseInt(str[i]);
    } {
      a[i] = Integer.parseInt(str[i]);
    } a[i] = Integer.parseInt(str[i]) a[i] a i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i Arrays.sort(a) Arrays.sort Arrays a for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i=i-2 i=i-2 i i-2 i 2 {
      aliceSum += a[i];
    } {
      aliceSum += a[i];
    } aliceSum += a[i] aliceSum a[i] a i for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    } int i=n-2; int i=n-2; i n-2 n 2 i>=0 i 0 i=i-2 i=i-2 i i-2 i 2 {
      bobSum += a[i];
      
    } {
      bobSum += a[i];
      
    } bobSum += a[i] bobSum a[i] a i System.out.println(aliceSum-bobSum) System.out.println System.out System System.out aliceSum-bobSum aliceSum bobSum String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int aliceSum = 0;
    int bobSum = 0;
    for(int i=0 ; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(a);
    for(int i=n-1; i>=0; i=i-2) {
      aliceSum += a[i];
    }
    for(int i=n-2; i>=0; i=i-2) {
      bobSum += a[i];
      
    }
    System.out.println(aliceSum-bobSum);
  }
}