defmodule Main do def main do beans_sum = IO.gets("") |> String.trim |> String.split |> Enum.take(2) |> Enum.map(&String.to_integer/1) |> List.foldl(1, fn x, acc -> x * acc end) age_sum = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) |> Enum.sum out(beans_sum, age_sum) end def out(beans_sum, age_sum) when beans_sum >= age_sum do IO.puts beans_sum-age_sum end def out(_, _) do IO.puts -1 end end