#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  string op = "+";
  V<> a(n);
  for (int i = 0; i < n; ++i) {
    if (i) {
      char c; cin >> c;
      op += c;
    }
    cin >> a[i];
    if (op[i] == '-') a[i] = -a[i];
  }

  constexpr lint inf = 9e18;
  V<lint> dp(10, -inf);
  dp[0] = a[0];
  for (int i = 1; i < n; ++i) {
    V<lint> ndp(10, -inf);
    for (int x = 0; x < 10; ++x) {
      for (int y = 0; y <= min(x + (op[i - 1] == '-'), 9); ++y) {
        ndp[y] = max(ndp[y], dp[x] + (y & 1 ? -a[i] : a[i]));
      }
    }
    swap(dp, ndp);
  }

  cout << *max_element(begin(dp), end(dp)) << '\n';
}