use std::cmp::max; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n * 2) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut even = vec![0; n + 1]; let mut odd = vec![0; n + 1]; for i in 0..n { even[i + 1] = even[i] + a[i * 2]; odd[i + 1] = odd[i] + a[i * 2 + 1]; } let mut ans = 0; for l in 0..n + 1 { let left = even[l] - odd[l]; let right = (odd[n] - odd[l]) - (even[n] - even[l]); ans = max(ans, left + right); } println!("{}", ans); }