mod io { #[macro_export] macro_rules! scan { ($r:expr, [$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($r, $t)).collect::>()); ($r:expr, ($($t:tt),*)) => (($(scan!($r, $t)),*)); ($r:expr, [u8]) => (io::scan($r).into_bytes()); ($r:expr, $t:ty) => (io::scan($r).parse::<$t>().unwrap()); } use std::io::{BufRead, ErrorKind}; pub fn scan(r: &mut R) -> String { let mut res = Vec::new(); loop { let buf = match r.fill_buf() { Ok(buf) => buf, Err(e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => panic!(e), }; let (done, used) = match buf.iter().position(u8::is_ascii_whitespace) { Some(i) => { res.extend_from_slice(&buf[..i]); (res.len() > 0, i + 1) } None => { res.extend_from_slice(buf); (false, buf.len()) } }; r.consume(used); if done || used == 0 { return res.into_iter().map(char::from).collect(); } } } } use std::io::{BufRead, Write}; fn run(reader: &mut R, writer: &mut W) { let (n, x) = scan!(reader, (usize, usize)); let s = scan!(reader, [usize; n]); let sum = s.iter().sum::(); let ans = sum - (n - 1) * x; writeln!(writer, "{}", ans).ok(); } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let mut reader = std::io::BufReader::new(stdin.lock()); let mut writer = std::io::BufWriter::new(stdout.lock()); run(&mut reader, &mut writer); }