let f (s:System.String) = s.Split(' ') |> Seq.map int let m = stdin.ReadLine() |> f |> Seq.toList |> function | [k;n;f] -> k*n | _ -> failwith "error!" let s = stdin.ReadLine() |> f |> Seq.sum if s > m then -1 else m%s |> printfn "%d"