#include <bits/stdc++.h>

constexpr int N = 1e5;

int n;

int a[N];
char op[N];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> n;
    std::cin >> a[0];
    int64_t sum = a[0];
    for (int i = 1; i < n; ++i) {
        std::cin >> op[i] >> a[i];
        sum += op[i] == '-' ? -a[i] : a[i];
    }
    
    int64_t ans = sum;
    int64_t cur = 0;
    
    for (int i = n - 1; i >= 1; --i) {
        cur += a[i];
        if (op[i] == '-') {
            sum += 2 * a[i];
            ans = std::max(ans, sum - 2 * cur);
            cur = 0;
        }
    }
    
    std::cout << ans << "\n";
    
    return 0;
}