#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, a[100000], imos[100001] = {}, sum = 0, ma = -1e+18;
  string op[100000];
  cin >> n;
  for (long long i = 0; i < n; i++) {
    if (i)
      cin >> op[i];
    else
      op[i] = "+";
    cin >> a[i];
    imos[i + 1] = imos[i] + a[i];
  }
  for (long long i = 0; i < n; i++) {
    if (op[i] == "-") {
      long long pos = i + 1, tmp = -a[i];
      while (op[pos] == "+" && pos < n) tmp -= a[pos++];
      ma = max(ma, sum + tmp + imos[n] - imos[pos]);
      sum -= a[i];
    } else
      sum += a[i];
  }
  cout << max(ma, sum) << endl;
  return 0;
}
