defmodule Main do def main do IO.read(:line) IO.read(:line) |> String.split() |> Enum.map(&String.to_integer/1) |> solve |> IO.puts() end defp solve(list) do list |> Enum.uniq() |> Enum.sort() |> (&[&1, &1 |> rotate]).() |> Enum.zip() |> Enum.map(fn {a, b} -> (a - b) |> abs end) |> Enum.min() end defp rotate(list) do (list |> Enum.slice(1..-1)) ++ [list |> List.first()] end end