using System; using System.Collections.Generic; public class Program { static void Main() { string data = Console.ReadLine(); string _age = Console.ReadLine(); string Mame_ = ""; string Fukuro_ = ""; string Family_ = ""; int i = 0; while (data.Substring(i, 1) != " ") { Mame_ = Mame_ + data.Substring(i, 1); i++; } i++; while (data.Substring(i, 1) != " ") { Fukuro_ = Fukuro_ + data.Substring(i, 1); i++; } Family_ = data.Substring(i + 1, 1); int Mame = Convert.ToInt32(Mame_); int Fukuro = Convert.ToInt32(Fukuro_); int Family = Convert.ToInt32(Family_); //豆の総数 int Mame_Kei = Fukuro * Mame; //家族の年齢 List age = new List(); string age_ = ""; for (int a = 0; a < _age.Length; a++) { if (_age.Substring(a, 1) != " ") { age_ = age_ + _age.Substring(a, 1); } else { age.Add(Convert.ToInt32(age_)); age_ = ""; } } age.Add(Convert.ToInt32(age_)); for (int c = 0; c < age.Count; c++) { Mame_Kei = Mame_Kei - age[c]; } if (Mame_Kei < 0) { Console.WriteLine("-1"); } else { Console.WriteLine(Mame_Kei.ToString()); } } }