
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n;
ll a[100010];
char op[100010];
char buf[8];
ll left=0,right=0,ans=-2e11;

int main() {
    scanf("%d",&n);
    scanf("%lld",&a[0]);
    left=a[0];
    for (int i=1;i<n;i++) {
        scanf("%s",buf);
        scanf("%lld",a+i);
        op[i]=buf[0];
        right+=a[i];
    }
    int idx=1;
    while (idx<n&&op[idx]=='+') {
        left+=a[idx];
        right-=a[idx];
        idx++;
    }
    ll tmp=0;
    while (idx<n) {
        left+=2*tmp;
        left-=a[idx];
        right-=a[idx];
        idx++;
        tmp=0;
        while (idx<n&&op[idx]=='+') {
            tmp+=a[idx];
            left-=a[idx];
            right-=a[idx];
            idx++;
        }
        ans=max(ans,left+right);
    }
    ans=max(ans,left+right);
    printf("%lld\n",ans);
}