/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment(" -Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int a[100005];
char c[100005];
bool used[100005];
int dp[100005][2];
signed main(){
	cin>>n;cin>>a[1]; 
	for(int i=2;i<=n;i++){
		cin>>c[i]>>a[i];
	}
	vector<int>vec;
	for(int i=1;i<=n;i++){
		if(used[i])continue;
		int now=i+1;
		while(now<=n&&c[now]=='+'){
			now++;
		}
		int sum=0;
		for(int j=i;j<now;j++){
			used[j]=1;
			sum+=a[j];
		}
		vec.push_back(sum);
	}
	#ifdef LOCAL
		for(int i=0;i<vec.size();i++){
			cerr<<vec[i]<<" ";
		}cerr<<endl;
	#endif
	if(vec.size()==1){
		cout<<vec[0]<<endl;
	}else{
		int v=vec[0]-vec[1];
		for(int i=2;i<vec.size();i++)v+=vec[i];
		cout<<v<<endl;
	}
	return 0;
}