#include <bits/stdc++.h>
using namespace std;
const long long N = 100010;
long long a[N], per[N];
vector<long long> sub;
int main() {
  long long n;
  cin >> n >> a[0];
  per[0] = a[0];
  long long abssum = a[0], ans = a[0];
  char op;
  for (long long j = 1; j < n; j++) {
    cin >> op >> a[j];
    per[j] = per[j - 1] + a[j];
    abssum += a[j];
    if (op == '+')
      ans += a[j];
    else {
      ans -= a[j];
      sub.push_back(j);
    }
  }
  for (long long j = 0; j < sub.size() - 1; j++) {
    long long p1 = sub[j], p2 = sub[j + 1];
    long long t = abssum -= (per[p2 - 1] - per[p1 - 1]) * 2;
    ans = max(ans, t);
    abssum -= a[p1] * 2;
  }
  cout << ans << endl;
}
