input_lines = readlines knf_arr = input_lines[0].split.map(&:to_i) k = knf_arr[0] n = knf_arr[1] beans = k * n familyAges_arr = input_lines[1].split.map(&:to_i) familyAges_arr.each do |value| beans -= value if beans < 0 beans = -1 break end end puts beans