use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_macros)]
macro_rules! dump (
    ($($arg:tt)*) => { {
        if cfg!(local) {
            let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
            r.expect("failed printing to stderr");
        }
    } }
);

#[allow(dead_code)]
struct Chrono {
    st: std::time::SystemTime,
}

#[allow(dead_code)]
impl Chrono {
    fn new() -> Chrono {
        Chrono { st: std::time::SystemTime::now() }
    }

    fn elapsed_ms(&self) -> i64 {
        let elapsed = self.st.elapsed().unwrap();
        elapsed.as_secs() as i64 * 1000 + elapsed.subsec_nanos() as i64 / 1_000_000
    }

    fn reset(&mut self) {
        self.st = std::time::SystemTime::now();
    }
}

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    pub fn line(&mut self) -> String {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|&c| c == '\n' || c == '\r')
            .take_while(|&c| !(c == '\n' || c == '\r'))
            .collect::<String>();
        self.buffer.clone()
    }

    pub fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    pub fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            if cfg!(local) {
                writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            }
            std::process::exit(0);
        }
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let n = sc.read();
        let mut a: Vec<i32> = sc.vec(n);
        a.sort();
        a.reverse();
        let mut alice = 0;
        let mut bob = 0;
        for (i, &x) in a.iter().enumerate() {
            if i % 2 == 0 {
                alice += x;
            } else {
                bob += x;
            }
        }
        println!("{}", alice - bob);
    }
}


Measured memory_bytes: 8572