#include<cstdio>
#include<algorithm>
#define maxn 100005
#define LL long long
#define INF (LL)(1e16)
using namespace std;
int n,a[maxn],f[maxn];
LL sum,ans=-INF,pre[maxn];
int main()
{
	scanf("%d%d",&n,&a[1]);
	for(int i=2;i<=n;i++)
	{
		char s[5];
		scanf("%s",s);
		if(s[0]=='-') f[i]=1;
		scanf("%d",&a[i]);
	}
	for(int i=n;i>0;i--) pre[i]=pre[i+1]+a[i];
	int la=1;
	while(la<=n&&!f[la]) sum+=1ll*a[la++];
	while(la<=n)
	{
		int la1=la+1; LL sum1=0;
		while(la1<=n&&!f[la1]) sum1+=1ll*a[la1++];
		if(la1<=n) ans=max(ans,sum-sum1-a[la]+pre[la1]);
		sum+=sum1-a[la]; la=la1; 
	}
	ans=max(ans,sum);
	printf("%lld\n",ans);
}