#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), sgn(n);
    for(int i = 0; i < n; i++) {
        char c = '+';
        if(i) cin >> c;
        sgn[i] = c == '+' ? 1 : -1;
        cin >> a[i];
    }
    const int N = 100'000;
    static ll opt[N + 1][2][3];
    for(int i = n; i >= 0; i--) {
        for(int flipped = 0; flipped <= 1; flipped++) {
            for(int has_flipped = 0; has_flipped <= 2; has_flipped++) {
                ll& ans = opt[i][flipped][has_flipped];
                if(i == n) {
                    ans = 0;
                } else {
                    ans = a[i] * sgn[i] * (flipped ? -1 : 1) + opt[i + 1][flipped][has_flipped];
                    if(sgn[i] == -1) {
                        ans = max(ans, a[i] * sgn[i] * (flipped ? -1 : 1) + opt[i + 1][not flipped][min(has_flipped + 1, 2)]);
                    }
                    if(has_flipped >= 1) {
                        ans = max(ans, a[i] * sgn[i] + opt[i + 1][0][0]);
                    }
                    if(has_flipped >= 2) {
                        ans = max(ans, a[i] * sgn[i] * -1 + opt[i + 1][1][1]);
                    }
                }
            }
        }
    }
    cout << opt[0][0][0] << endl;
    return 0;
}
