// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

#include <iomanip>

#define ALL(x) (x).begin(), (x).end()

#define rt return

#define dll(x) scanf("%I64d",&x)

#define xll(x) printf("%I64d\n",x)

#define sz(a) int(a.size())

#define all(a) a.begin(), a.end()

#define rep(i,x,n) for(int i=x;i<n;i++)

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define eps 1e-6

#define gg(x) getInt(&x)

#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

inline void getInt(int* p);

const int maxn=1000010;

// const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/

int n;

char op[maxn];

int a[maxn];

ll dp[maxn/10][4];

const ll inf=(ll)(1e18);



int main()

{

    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);

    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

    gbtb;

    cin>>n;

    cin>>a[1];

    repd(i,2,n)

    {

        cin>>op[i]>>a[i];

    }

    dp[1][0]=a[1];

    dp[1][1]=dp[1][2]=-inf;

    repd(i,2,n)

    {

        if(op[i]=='+')

        {

            dp[i][0]=max(dp[i-1][0],dp[i-1][1])+a[i];

            dp[i][1]=dp[i-1][1]-a[i];

            dp[i][2]=dp[i-1][2]+a[i];

        }else

        {

            dp[i][0]=-inf;

            dp[i][1]=max(dp[i-1][0],dp[i-1][1])-a[i];

            dp[i][2]=max(dp[i-1][2],dp[i-1][1])+a[i];

        }

    }

    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

    

    

    return 0;

}



inline void getInt(int* p) {

    char ch;

    do {

        ch = getchar();

    } while (ch == ' ' || ch == '\n');

    if (ch == '-') {

        *p = -(getchar() - '0');

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 - ch + '0';

        }

    }

    else {

        *p = ch - '0';

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 + ch - '0';

        }

    }

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cmath>

#include<cstring>

#include<string>

#include<algorithm>

#include<vector>



#define maxn 205

#define maxm 10000005



using namespace std;



inline int getint()

{

	int num=0,flag=1;char c;

	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;

	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();

	return num*flag;

}



int n;

long long F[3];



int main()

{

	n=getint();F[1]=F[2]=-1ll<<60;

	while(n--)

	{

		int x=getint();

		F[0]+=x,F[1]-=x,F[2]+=x;

		if(x<0)F[2]=max(F[2],F[1]),F[1]=max(F[1],F[0]);

		F[1]=max(F[1],F[2]),F[0]=max(F[0],F[1]);

	}

	printf("%lld\n",F[0]);

}

// Fastest known solution for this problem: