defmodule Main do
  def main() do
    _n =
      IO.gets("")
      |> String.trim()
      |> String.to_integer()
    a =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      |> Enum.sort(:desc)
    take(a)
  end

  def take(a) do
    alice =
      Enum.take_every(a, 2)
      |> Enum.sum()
    bob = Enum.sum(a) - alice
    alice - bob
  end
end
