use std::io::Read; const INF:usize=usize::MAX>>2; fn main(){ let mut input = "".to_owned(); std::io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_ascii_whitespace(); macro_rules! read(($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap())); let n=read!(usize); let mut v=vec![!0;n]; for i in 0..n{ v[i]=read!(usize); } if n==1{ println!("{}",v[0]); std::process::exit(0); } let mut dp=vec![INF;n]; dp[0]=v[0]; dp[1]=v[1]; for i in 2..n{ dp[i]=dp[i-1]; for j in 0..i-1{ dp[i]=dp[i].max(dp[j]+v[i]); } } println!("{}",dp[n-1]); }