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

public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} main {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) int num = Integer.parseInt((br.readLine())); num Integer.parseInt((br.readLine())) Integer.parseInt Integer (br.readLine()) br.readLine br String[] stringArr = br.readLine().split(" "); stringArr br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Integer[] intArr = new Integer[num]; intArr new Integer[num] num int answer = 0; answer 0 for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			} int i = 0; int i = 0; i 0 i < intArr.length i intArr.length intArr intArr.length i++ i++ i {
				intArr[i] = Integer.valueOf(stringArr[i]);
			} {
				intArr[i] = Integer.valueOf(stringArr[i]);
			} intArr[i] = Integer.valueOf(stringArr[i]) intArr[i] intArr i Integer.valueOf(stringArr[i]) Integer.valueOf Integer stringArr[i] stringArr i Arrays.sort(intArr, Collections.reverseOrder()) Arrays.sort Arrays intArr Collections.reverseOrder() Collections.reverseOrder Collections for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			} int i = 0; int i = 0; i 0 i < intArr.length i intArr.length intArr intArr.length i++ i++ i {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			} {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			} if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				} i % 2 == 0 i % 2 i 2 0 {
					answer += intArr[i];
				} answer += intArr[i] answer intArr[i] intArr i {
					answer -= intArr[i];
				} answer -= intArr[i] answer intArr[i] intArr i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
} public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			int num = Integer.parseInt((br.readLine()));
			String[] stringArr = br.readLine().split(" ");
			Integer[] intArr = new Integer[num];
			int answer = 0;

			for (int i = 0; i < intArr.length; i++) {
				intArr[i] = Integer.valueOf(stringArr[i]);
			}

			Arrays.sort(intArr, Collections.reverseOrder());

			for (int i = 0; i < intArr.length; i++) {
				if (i % 2 == 0) {
					answer += intArr[i];
				} else {
					answer -= intArr[i];
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}