use std::io::Read; fn r(p: &mut Vec<&str>) -> i64 { let s = p.pop().unwrap(); match s { "+" => r(p) + r(p), "-" => -r(p) + r(p), _ => s.parse().unwrap(), } } fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut s: Vec<_> = s.split_whitespace().skip(1).collect(); println!("{}", r(&mut s)); }