import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}
 import java.io.*; io.* java import java.math.*; math.* java import java.util.*; util.* java public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
} Main public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	} main { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	} FastScanner I = new FastScanner(); I new FastScanner() OutPut O = new OutPut(); O new OutPut() int N = I.nextInt(); N I.nextInt() I.nextInt I int[] a = new int[N]; a new int[N] N for (int i = 0; i < N; i++) a[i] = I.nextInt(); int i = 0; int i = 0; i 0 i < N i N i++ i++ i a[i] = I.nextInt(); a[i] = I.nextInt() a[i] a i I.nextInt() I.nextInt I Arrays.sort(a) Arrays.sort Arrays a int A = 0; A 0 int B = 0; B 0 int ptr = N-1; ptr N-1 N 1 while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		} ptr>=0 ptr 0 {
			A+=a[ptr];
			ptr-=2;
		} A+=a[ptr] A a[ptr] a ptr ptr-=2 ptr 2 ptr = N-2 ptr N-2 N 2 while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		} ptr>=0 ptr 0 {
			B+=a[ptr];
			ptr-=2;
		} B+=a[ptr] B a[ptr] a ptr ptr-=2 ptr 2 O.pln(A-B) O.pln O A-B A B String[] args args public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;} ceil {long ans = num/den; if (num%den!=0) 
	ans++; return ans;} long ans = num/den; ans num/den num den if (num%den!=0) 
	ans++; num%den!=0 num%den num den 0 ans++ ans return ans; ans long num num long den den public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	} GCD {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	} if (a==0||b==0) return Math.max(a,b); a==0||b==0 a==0 a 0 b==0 b 0 return Math.max(a,b); Math.max(a,b) Math.max Math a b return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b)); GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b)) GCD Math.min(a, b) Math.min Math a b Math.max(a, b)%Math.min(a, b) Math.max(a, b) Math.max Math a b Math.min(a, b) Math.min Math a b long a a long b b public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	} FastExp {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	} long ans=1; ans 1 while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		} exp>0 exp 0 {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		} if (exp%2==1) ans*=base; exp%2==1 exp%2 exp 2 1 ans*=base ans base exp/=2 exp 2 base*=base base base base%=mod base mod ans%=mod ans mod return ans; ans long base base long exp exp long mod mod public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);} ModInv {return FastExp(num,mod-2,mod);} return FastExp(num,mod-2,mod); FastExp(num,mod-2,mod) FastExp num mod-2 mod 2 mod long num num long mod mod static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	} FastScanner BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st=new StringTokenizer(""); st new StringTokenizer("") String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} next {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st=new StringTokenizer(br.readLine());
				} st=new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {return Integer.parseInt(next());} nextInt {return Integer.parseInt(next());} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {return Long.parseLong(next());} nextLong {return Long.parseLong(next());} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	} OutPut PrintWriter w = new PrintWriter(System.out); w new PrintWriter(System.out) void pln(int x) {w.println(x);w.flush();} pln {w.println(x);w.flush();} w.println(x) w.println w x w.flush() w.flush w int x x void pln(long x) {w.println(x);w.flush();} pln {w.println(x);w.flush();} w.println(x) w.println w x w.flush() w.flush w long x x void pln(String x) {w.println(x);w.flush();} pln {w.println(x);w.flush();} w.println(x) w.println w x w.flush() w.flush w String x x void pln(char x) {w.println(x);w.flush();} pln {w.println(x);w.flush();} w.println(x) w.println w x w.flush() w.flush w char x x void pln(StringBuilder x) {w.println(x);w.flush();} pln {w.println(x);w.flush();} w.println(x) w.println w x w.flush() w.flush w StringBuilder x x void p(int x) {w.print(x);w.flush();} p {w.print(x);w.flush();} w.print(x) w.print w x w.flush() w.flush w int x x void p(long x) {w.print(x);w.flush();} p {w.print(x);w.flush();} w.print(x) w.print w x w.flush() w.flush w long x x void p(String x) {w.print(x);w.flush();} p {w.print(x);w.flush();} w.print(x) w.print w x w.flush() w.flush w String x x void p(char x) {w.print(x);w.flush();} p {w.print(x);w.flush();} w.print(x) w.print w x w.flush() w.flush w char x x void p(StringBuilder x) {w.print(x);w.flush();} p {w.print(x);w.flush();} w.print(x) w.print w x w.flush() w.flush w StringBuilder x x public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
} public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
} Main
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}

