#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) {
    fread_unlocked(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm)
    while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else
    while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}
int main() {
  int N = getint();
  char c;
  long long dp0 = getint();
  long long dp1 = -1e18;
  bool hajimete = 0;
  long long purasu = 0;
  for (int i = 0; i < (N - 1); i++) {
    int a = 0;
    if (ci - cn + 16 > cm) {
      c = getcha();
      getchar();
      while ((ct = getcha()) >= '0') a = a * 10 + ct - '0';
    } else {
      c = *ci++;
      ci++;
      while ((ct = *ci++) >= '0') a = a * 10 + ct - '0';
    }
    if (hajimete == 0) {
      if (c == '+') {
        dp0 += a;
      } else {
        hajimete = 1;
        dp0 -= a;
      }
    } else {
      if (c == '+') {
        purasu += a;
      } else {
        dp1 = max(dp1 + purasu + a, dp0 + a - purasu);
        dp0 += purasu - a;
        purasu = 0;
      }
    }
  }
  printf("%lld", max(dp0, dp1) + purasu);
  return 0;
}
