#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline T read(T &f) {
  f = 0;
  int x = 1;
  char c = getchar();
  while (!isdigit(c)) x = c == '-' ? -1 : 1, c = getchar();
  while (isdigit(c)) (f *= 10) += c & 15, c = getchar();
  return f *= x;
}
const int N = 100000 + 5;
using int64 = long long;
int n, cnt, A[N], col[N];
int64 s[N], sum[N], sl[N];
int main() {
  read(n);
  for (int i = (1), ___ = (n); i <= ___; ++i) {
    static int op[10];
    if (i == 1)
      read(A[i]), col[++cnt] = 1, s[1] = A[i];
    else {
      scanf("%s", op), read(A[i]);
      if (*op == '-') {
        col[++cnt] = -1;
        s[i] = -A[i];
      } else {
        if (col[cnt] == 1) {
          s[cnt] += A[i];
        } else {
          col[++cnt] = 1;
          s[cnt] = A[i];
        }
      }
    }
  }
  for (int i = (cnt), ___ = (1); i >= ___; --i) {
    sum[i] = sum[i + 1] + abs(s[i]);
  }
  int64 Ans = -(1ll << 60), ret = 0;
  for (int i = (1), ___ = (cnt); i <= ___; ++i) {
    sl[i] = sl[i - 1] + s[i];
  }
  cerr << cnt << endl;
  for (int i = (1), ___ = (cnt); i <= ___; ++i) {
    if (col[i + 1] == -1) {
      chkmax(Ans, sl[i + 1] - s[i + 2] + sum[i + 3]);
    }
  }
  chkmax(Ans, sl[cnt]);
  cout << Ans << endl;
  return 0;
}
