#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
ll dp [100001] [3];
const ll INF = 1e17;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	fill(dp [0],dp [N + 1],-INF);
	dp [0] [0] = 0;
	FOR(i,0,N){
		ll A;
		char C;
		if(i == 0){
			cin >> A;
			chmax(dp [i + 1] [0],dp [i] [0] + A);
		}
		else{
			cin >> C >> A;
			for(int j = 0;j <= 2;j++){
				for(int k = C == '-';k <= min(j + (C == '-'),2);k++){
					chmax(dp [i + 1] [k],dp [i] [j] + (k % 2 == 0 ? A : -A));
				}
			}
		}
	}

	cout << *max_element(dp [N],dp [N + 1]) << endl;

	return 0;
}
