#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T next_num() {
  T i = 0;
  char c;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  bool flag = c == '-';
  flag ? c = getchar() : 0;
  while (i = i * 10 - '0' + c, isdigit(c = getchar()))
    ;
  return flag ? -i : i;
}
template <class T1, class T2>
inline void apmax(T1 &a, const T2 &b) {
  if (a < b) a = b;
}
template <class T1, class T2>
inline void apmin(T1 &a, const T2 &b) {
  if (b < a) a = b;
}
const int N = 100010;
const long long LINF = 0x7f7f7f7f7f7f7f7fll;
int main() {
  int n = (next_num<int>());
  long long f[3] = {(next_num<int>()), -LINF, -LINF};
  for (int i = 2; i <= n; i++) {
    char c;
    while (c = getchar(), c != '+' && c != '-')
      ;
    int val = (next_num<int>());
    if (c == '-') {
      f[2] = f[1], f[1] = f[0], f[0] = -LINF;
    }
    if (f[1] != -LINF) {
      f[1] -= val;
      if (f[2] != -LINF) {
        apmax(f[1], f[2] += val);
      }
      apmax(f[0], f[1]);
    }
    assert(f[0] >= f[1] && f[1] >= f[2]);
  }
  printf("%lld\n", f[0]);
  return 0;
}
