#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long n, s[100010];
int main() {
  cin >> n;
  char op = '+';
  long long befpo = -1;
  for (int i = 0; i < n; i++) {
    if (i) cin >> op;
    long long a;
    cin >> a;
    if (op == '+') {
      if (~befpo)
        befpo += a;
      else
        befpo = a;
    } else {
      if (~befpo) v.push_back(befpo);
      befpo = -1;
      v.push_back(-a);
    }
  }
  if (~befpo) v.push_back(befpo);
  n = v.size();
  s[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    s[i] = s[i + 1] + abs(v[i]);
  }
  long long ans = -1e17, sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += v[i];
    if (v[i] > 0) continue;
    ans = max(ans, sum + -v[i + 1] + s[i + 2]);
    ;
  }
  cout << ans << endl;
  return 0;
}
