import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 }
} import java.util.*; util.* java public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 } main {
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] a = new int[N]; a new int[N] N for(int i=0;i<N;i++) a[i]=sc.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i a[i]=sc.nextInt(); a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int allsum = 0; allsum 0 int sumA = 0; sumA 0 Arrays.sort(a) Arrays.sort Arrays a for(int i=0;i<N;i++) allsum+=a[i]; int i=0; int i=0; i 0 i<N i N i++ i++ i allsum+=a[i]; allsum+=a[i] allsum a[i] a i if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   } N%2==1 N%2 N 2 1 {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   } for(int i=0;i<N;i+=2) sumA+=a[i]; int i=0; int i=0; i 0 i<N i N i+=2 i+=2 i 2 sumA+=a[i]; sumA+=a[i] sumA a[i] a i {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   } for(int i=1;i<N;i+=2) sumA+=a[i]; int i=1; int i=1; i 1 i<N i N i+=2 i+=2 i 2 sumA+=a[i]; sumA+=a[i] sumA a[i] a i System.out.println(2*sumA-allsum) System.out.println System.out System System.out 2*sumA-allsum 2*sumA 2 sumA allsum String[] args args public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 }
} Main
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i]=sc.nextInt();
   
   int allsum = 0;
   int sumA = 0;
   
   Arrays.sort(a);
   for(int i=0;i<N;i++) allsum+=a[i];
   if(N%2==1)
   {
     for(int i=0;i<N;i+=2) sumA+=a[i];
   }
   else   
   {
     for(int i=1;i<N;i+=2) sumA+=a[i];
   }
   
   System.out.println(2*sumA-allsum);
 }
}