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

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    }
} Main public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(input.readLine()); n Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input StringTokenizer tokenizer = new StringTokenizer(input.readLine()); tokenizer new StringTokenizer(input.readLine()) int [] values = new int[n]; values new int[n] n for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        } {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        } values[i] = Integer.parseInt(tokenizer.nextToken()) values[i] values i Integer.parseInt(tokenizer.nextToken()) Integer.parseInt Integer tokenizer.nextToken() tokenizer.nextToken tokenizer Arrays.sort(values) Arrays.sort Arrays values boolean state = true; state true int sum1 =0 sum1 0 sum2 = 0; sum2 0 for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        } int i = n - 1; int i = n - 1; i n - 1 n 1 i > -1 i -1 1 i-- i-- i {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        } {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        } if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            } state {
                sum1 += values[i];
                state = false;
            } sum1 += values[i] sum1 values[i] values i state = false state false {
                sum2  += values[i];
                state = true;
            } sum2  += values[i] sum2 values[i] values i state = true state true System.out.println(Math.abs(sum1 - sum2)) System.out.println System.out System System.out Math.abs(sum1 - sum2) Math.abs Math sum1 - sum2 sum1 sum2 String[] args args public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    }
} public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(values);

        boolean state = true;
        int sum1 =0, sum2 = 0;

        for (int i = n - 1; i > -1; i--) {
            if (state){
                sum1 += values[i];
                state = false;
            }else {
                sum2  += values[i];
                state = true;
            }
        }

        System.out.println(Math.abs(sum1 - sum2));
    }
}
