#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> dp1(3, LLONG_MIN);
  vector<ll> dp2(3, LLONG_MIN);
  cin >> dp1[0];
  n--;
  for (int i = 0; i < (int)(n); i++) {
    char op;
    cin >> op;
    ll a;
    cin >> a;
    if (op == '+') {
      dp2[0] = dp1[0] + a;
      dp2[1] = dp1[1] - a;
      dp2[2] = dp1[2] + a;
    } else {
      dp2[0] = dp1[0] - a;
      dp2[1] = max(dp1[0] - a, dp1[1] + a);
      dp2[2] = max(dp1[1] + a, dp1[2] + a);
    }
    swap(dp1, dp2);
  }
  ll ma = LLONG_MIN;
  for (int i = 0; i < (int)(3); i++) {
    chmax(ma, dp1[i]);
  }
  cout << ma << endl;
}
