use std::io; use std::io::{Stdin, BufRead}; struct Input { grain_number: i32, bag_number: i32, family_members: i32, ages: Vec, } fn main() { let mut stdin = io::stdin(); let input = read_input(&mut stdin); let n = input.grain_number * input.bag_number; let result = input.ages.iter().fold(0, |a, b| a + b); let result = n - result; if result < 0 { print!("-1"); } else { print!("{}", result); } } fn read_input(stdin: &mut Stdin) -> Input { let mut lock = stdin.lock(); let mut s = String::new(); lock.read_line(&mut s).expect("can not read first line"); let tokens: Vec = s.trim_end().split(" ").map(|s| s.parse().expect("can't parse")).collect(); s.clear(); lock.read_line(&mut s).expect("can not read first line"); let ages: Vec = s.trim_end().split(" ").map(|s| s.parse().expect("can't parse")).collect(); Input { grain_number: tokens[0], bag_number: tokens[1], family_members: tokens[2], ages, } }