open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ass = reada int
    let ass = Array.sort ass |> Array.rev
    let total = Array.sum ass
    let mutable alice = 0
    for i in 0..2..n-1 do
        alice <- alice + ass.[i]
    alice - (total - alice) |> printfn "%d"
    0
