//void __(){
//    _(int,n);
//    vl a(n);
//    string signs;
//    ll ans = 0;
//    char sign = '+';
//    rep(i,n){
//        cin >> a[i];
//        ans += (sign == '+' ? 1 : -1) * a[i];
//        if(i+1 < n)
//            cin >> sign;
//        signs.pb(sign);
//    }
//    ll total = 0;
//    rep(i,n)
//        total += a[i];
//    ll cur_signed = a[0];
//    ll cur_abs = a[0];
//    ll last_signed = -INF;
//    ll last_abs = 0;
//    rep(i,n-1){
//        if(signs[i] == '-'){
//            ll in_between = cur_abs - last_abs;
//            ll later = total - cur_abs;
//            ll cur = last_signed - in_between + later;
//            ans = max(ans,cur);
//            last_signed = cur_signed;
//            last_abs = cur_abs;
//        }
//        cur_signed += (signs[i] == '+' ? 1 : -1)*a[i+1];
//        cur_abs += a[i+1];
//    }
//    print ans;
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_ZERO_INT(i,r) for(int i = 0; i < (r); ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll INF = ll(2e18) + 666;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout) 
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }

    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
void __(){
    _(int,n);
    vl a(n);
    string signs;
    ll ans = 0;
    char sign = '+';
    rep(i,n){
        cin >> a[i];
        ans += (sign == '+' ? 1 : -1) * a[i];
        if(i+1 < n)
            cin >> sign;
        signs.pb(sign);
    }
    ll total = 0;
    rep(i,n)
        total += a[i];
    ll cur_signed = a[0];
    ll cur_abs = a[0];
    ll last_signed = -INF;
    ll last_abs = 0;
    rep(i,n-1){
        if(signs[i] == '-'){
            ll in_between = cur_abs - last_abs;
            ll later = total - cur_abs;
            ll cur = last_signed - in_between + later;
            ans = max(ans,cur);
            last_signed = cur_signed;
            last_abs = cur_abs;
        }
        cur_signed += (signs[i] == '+' ? 1 : -1)*a[i+1];
        cur_abs += a[i+1];
    }
    print ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}



Measured memory_bytes: 1280