import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
} Main public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  } main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc ArrayList<Integer> a = new ArrayList<Integer>(); a new ArrayList<Integer>() int ans = 0; ans 0 for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      a.add(sc.nextInt());
    } {
      a.add(sc.nextInt());
    } a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc a.sort(Collections.reverseOrder()) a.sort a Collections.reverseOrder() Collections.reverseOrder Collections for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    } {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    } if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      } (i % 2) == 0 (i % 2) i 2 0 {
        ans += a.get(i);
      } ans += a.get(i) ans a.get(i) a.get a i {
        ans -= a.get(i);
      } ans -= a.get(i) ans a.get(i) a.get a i 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 n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
} public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
}