// yukicoder My Practice // author: Leonardone @ NEETSDKASU use std::io; fn get_line() -> String { let mut input = String::new(); io::stdin().read_line(&mut input).ok().expect(""); return String::from(input.trim()); } fn get_words() -> Vec { get_line() .split_whitespace() .map(String::from) .collect() } fn get_integers() -> Vec { get_line() .split_whitespace() .map(|x| String::from(x).parse::().unwrap()) .collect() } fn main() { let _ = get_line(); let nums = get_integers(); let (ans, _) = nums .iter() .fold((0,0), |(ans, mx), &x| if x > mx { (ans, x) } else { if ans < x { (x, mx) } else { (ans, mx) } } ); println!("{}", ans); }