#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <bitset>
#define ll long long
#define rep(x,n) for(ll (x)=0;(x)<n;(x)++)
#define rep1(x,n) for(ll (x)=1;(x)<=n;(x)++)
#define ios::sync_with_stdio(0);
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
using namespace std;

const ll N=100010;
ll a[N],per[N];
vector<ll> sub;

int main()
{
    #ifdef LOCAL
        //freopen("C_data.txt","r",stdin);
    #endif // LOCAL
    ll n;
    ll
    cin>>n>>a[0];
    per[0]=a[0];
    ll abssum=a[0],ans=a[0];
    char op;
    for(ll j=1;j<n;j++)
    {
        cin>>op>>a[j];
        per[j]=per[j-1]+a[j];
        abssum+=a[j];
        if(op=='+') ans+=a[j];
        else
        {
            ans-=a[j];
            sub.push_back(j);
        }
    }
    for(ll j=0;j<sub.size()-1;j++)
    {
        ll p1=sub[j],p2=sub[j+1];
        ll t=abssum-=(per[p2-1]-per[p1-1])*2;
        ans=max(ans,t);
        abssum-=a[p1]*2;
    }
    cout<<ans<<endl;
}
