use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); it.next(); let a: Vec = it.map(|s| s.parse().unwrap()).collect(); let mut sum = 0; for a in a.chunks_exact(2) { sum += a[1] - a[0]; } let mut ans = sum; for a in a.chunks_exact(2) { sum += 2 * (a[0] - a[1]); ans = std::cmp::max(ans, sum); } println!("{}", ans); } fn main() { run(); }