#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-4;
const long double pi = acos(-1.0);
int n;
bool m[1 << 17];
long long a[1 << 17];
long long s[1 << 17];
long long sx[1 << 17];
vector<int> v;
int main() {
  cin >> n;
  cin >> a[0];
  for (int i = 1; i <= n - 1; i++) {
    char t;
    cin >> t >> a[i];
    if (t == '-') {
      m[i] = true;
      v.push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
    if (!m[i])
      sx[i + 1] = sx[i] + a[i];
    else
      sx[i + 1] = sx[i] - a[i];
  }
  long long ans = sx[n];
  for (int i = 0; i < v.size() - 1; i++) {
    int le = v[i], ri = v[i + 1];
    long long z = sx[le] - (s[ri] - s[le]) + s[n] - s[ri];
    ans = max(ans, z);
  }
  cout << ans << endl;
  return 0;
}
