use std::io::*; use std::str::FromStr; #[allow(dead_code)] fn read() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } #[allow(dead_code)] struct Main {} #[allow(dead_code)] impl Main {} fn main() { let n = read::(); let mut sushis = vec![0; n]; for i in 0..n { sushis[i] = read::() } let mut p = 0; let mut q = 0; for i in 0..n { let new_p = q + sushis[i]; q = if p > q { p } else { q }; p = new_p; } println!("{}", if p > q { p } else { q }); }