#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 4e18;
int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n; cin >> n;
    vi arr(1,0), ps;
    char si = '+';
    for(int i=0, cur;i<n;i++){
        if(i) cin >> si;
        cin >> cur;
        if(si == '+') arr.back() += cur;
        else arr.pb(cur);
    }
    n = arr.size();
    ps.pb(arr[0]);
    for(int i=1;i<n;i++) ps.pb(ps.back() + arr[i]);
    int res = arr[0] - (ps.back() - ps[0]);
    for(int i=1;i<n;i++){
        res = max(res, arr[0] - (ps[i-1] - ps[0]) - arr[i] + (ps.back() - ps[i]));
    }
    cout << res<<endl;
    return 0;
}
