pub mod io { use std::io::{Read, ErrorKind}; pub struct Scanner { r: R, buf: Vec, pos: usize, cap: usize } impl Scanner { const SIZE: usize = 8000; pub fn new(r: R) -> Self { Self { r, buf: Vec::new(), pos: 0, cap: 0 } } fn set_pos(&mut self, f: fn(&u8) -> bool) -> usize { let mut pos = self.pos; loop { if pos == self.cap { if self.cap == self.buf.len() { if self.pos > 0 { self.buf.copy_within(self.pos..self.cap, 0); self.cap -= self.pos; pos -= self.pos; self.pos = 0; } else { self.buf.resize(self.buf.len() + Self::SIZE, 0); } } match unsafe { self.r.read(self.buf.get_unchecked_mut(self.cap..)) } { Ok(0) => return pos, Ok(n) => self.cap += n, Err(e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => panic!("{}", e), } } match unsafe { self.buf.get_unchecked(pos..self.cap).iter().position(f) } { Some(i) => return pos + i, None => pos = self.cap, } } } pub fn next(&mut self) -> &str { self.pos = self.set_pos(|b| !b.is_ascii_whitespace()); let pos = self.set_pos(u8::is_ascii_whitespace); let buf = &self.buf[self.pos..pos]; self.pos = pos; std::str::from_utf8(buf).unwrap() } } #[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; scan!($r, usize)]) }; ($r:expr, ($($t:tt),*)) => { ($(scan!($r, $t)),*) }; ($r:expr, Usize1) => { scan!($r, usize) - 1 }; ($r:expr, Bytes) => { scan!($r, String).into_bytes() }; ($r:expr, $t:ty) => { $r.next().parse::<$t>().unwrap() }; } #[macro_export] macro_rules! input { ($($($v:ident)* : $t:tt),* $(,)?) => { let stdin = std::io::stdin(); let ref mut scanner = io::Scanner::new(stdin.lock()); $(let $($v)* = scan!(scanner, $t);)* }; } } fn main() { input! { n: usize, a: [u64; n], } println!("{}", a.iter().sum::()); }