mod io { use std::io::{BufRead, ErrorKind}; use std::str::FromStr; pub fn scan(r: &mut R) -> T { let mut tmp = 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, buf) = { match buf.iter().position(u8::is_ascii_whitespace) { Some(i) => (i > 0 || tmp.len() > 0, i + 1, &buf[..i]), None => (buf.is_empty(), buf.len(), buf), } }; if done { let buf = { if tmp.is_empty() { buf } else { tmp.extend_from_slice(buf); &tmp } }; let res = std::str::from_utf8(buf).unwrap().parse().ok().unwrap(); r.consume(used); return res; } tmp.extend_from_slice(buf); r.consume(used); } } } #[allow(unused_macros)] fn run(reader: &mut R, writer: &mut W) { macro_rules! scan { ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::>()); (($($t:tt),*)) => (($(scan!($t)),*)); ([u8]) => (scan!(String).into_bytes()); ($t:ty) => (io::scan::<_, $t>(reader)); } macro_rules! println { ($($arg:tt)*) => (writeln!(writer, $($arg)*).ok()); } let n = scan!(usize); let a = scan!([u64; n]); println!("{}", a.iter().sum::()); } 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); }