#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }

    let n = readl!(usize);
    let s = readlvec!(String);
    let mut a = vec![0; n];
    a[0] = s[0].parse().unwrap();
    let mut sign = vec![false; n-1];
    for i in 0..n-1 {
        sign[i] = s[i*2+1] == "-";
        if sign[i] {
            a[i+1] = -s[i*2+2].parse::<i64>().unwrap();
        } else {
            a[i+1] = s[i*2+2].parse().unwrap();
        }
    }
    let a = a;
    
    // debug!(sign);
    // let mut dp = vec![[0;4]; n+1];
    // dp[0][1] = -1_000_000_000_000_000;
    let inf = 1_000_000_000_000_000;
    let mut dp = [-inf;3];
    dp[0] = 0;
    for i in 0..n {
        let mut nex = [-inf; 3];
        {
            let nv = dp[0] + a[i];
            nex[0] = max(nex[0], nv);
            if i >= 1 && sign[i-1] {
                nex[1] = max(nex[1], nv);
            }
        }
        {
            let nv = dp[1] - a[i];
            nex[1] = max(nex[1], nv);
            nex[0] = max(nex[0], nv);
            if i >= 1 && sign[i-1] {
                nex[2] = max(nex[2], nv);
            }
        }
        {
            let nv = dp[2] + a[i].abs();
            nex[2] = max(nex[2], nv);
            nex[0] = max(nex[0], nv);
        }
        dp = nex;
        // dp[i+1] = dp[i];
        // dp[i+1][0] += a[i];
        // dp[i+1][1] -= a[i];
        // dp[i+1][0] = max(dp[i+1][0], dp[i][1]+a[i]);
        // if i >= 2 && sign[i-2] {
        //     debug!(i);
        //     dp[i+1][1] = max(dp[i+1][1], dp[i][0]-a[i]);
        // }
    }
    printfln!("{}", max(dp[0], max(dp[1], dp[2])));
    // debug!(dp);
    // println!("{}", max(dp[n][0], dp[n][1]));


}


Measured memory_bytes: 15736