defmodule Main do def main do beans_sum = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) |> Enum.take(2) |> sum(0) age_sum = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) |> Enum.sum IO.puts beans_sum IO.puts age_sum if beans_sum >= age_sum do IO.puts beans_sum-age_sum else IO.puts -1 end end def sum([], acc) do acc end def sum([head|tail], acc) do sum(tail, acc*head) end end