use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut splits = s.trim().split_whitespace(); let n = splits.next().unwrap().parse::().unwrap(); let mut ak: Vec = Vec::new(); for _ in 0..n { ak.push(splits.next().unwrap().parse::().unwrap()); } //debug!(n, v); let mut dp: [usize; 1000] = [0; 1000]; if n==1 { println!("{}", ak[0]);return; } dp[0] = ak[0]; dp[1] = std::cmp::max(ak[1], ak[0]); for i in 2..n { dp[i] = std::cmp::max(dp[i-1], dp[i-2]+ak[i]); } println!{"{}", dp[n-1]}; }