struct Scanner { buf_read: BR, } impl Scanner
{ fn new(buf_read: BR) -> Scanner
{ Scanner { buf_read: buf_read } } fn read_until_f

(&mut self, predicate: P) -> std::io::Result where P: std::ops::Fn(&u8) -> bool, { use std::io::BufRead; let mut buf = std::vec::Vec::new(); loop { let (done, used) = { let available: &[u8] = match self.buf_read.fill_buf() { Ok(b) => b, Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => continue, Err(e) => return Err(e), }; match available.iter().position(&predicate) { Some(i) => { buf.extend_from_slice(&available[..i + 1]); (true, i + 1) } None => { buf.extend_from_slice(available); (false, available.len()) } } }; self.buf_read.consume(used); if done || used == 0 { return match String::from_utf8(buf) { Ok(s) => Ok(s), Err(_) => Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "error")), } } } } fn next(&mut self) -> T where < T as std::str::FromStr >::Err: std::fmt::Debug { use ::std::str::FromStr; let mut with_delim = self.read_until_f(|&c| { c == b' ' || c == b'\n' }).unwrap(); with_delim.pop(); FromStr::from_str(with_delim.as_str()).unwrap() } fn ni(&mut self) -> i32 { self.next() } fn nl(&mut self) -> i64 { self.next() } fn ns(&mut self) -> String { self.next() } } fn main() { let stdin = std::io::stdin(); let mut scanner = Scanner::new(stdin.lock()); let mut remain = scanner.ni() * scanner.ni(); for _ in 0..scanner.ni() { remain -= scanner.ni(); } if remain < 0 { remain = -1; } println!("{}", remain); }