use std::{ collections::{BTreeSet, HashMap}, hash::Hash, }; fn main() { proconio::input! { n: usize, mut v: [i64; n], } v.reverse(); let mut value = 0; let mut i = 0; while i < n { let v2 = *v.get(i + 1).unwrap_or(&0); if v[i] >= v2 { value += v[i]; i += 2; } else { value += v2; i += 3; } } println!("{value}"); }