#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(1e5 + 5);
int s1, s2, as, n;
int sz[MAXN], fh[MAXN];
char c[5];
int main() {
  scanf("%d", &n);
  scanf("%d", &as);
  getchar();
  for (int i = 1; i <= n - 1; i++) {
    scanf("%s", c);
    scanf("%d", &sz[i]);
    fh[i] = c[0];
  }
  s1 = s2 = -0x3fffffff;
  for (int i = 1; i <= n - 1; i++) {
    if (fh[i] == '-') {
      as -= sz[i];
      s1 -= sz[i];
      s2 += sz[i];
      s1 = max(s1, s2);
      s2 = max(as, s2);
    } else {
      as += sz[i];
      s1 += sz[i];
      s2 -= sz[i];
    }
    s2 = max(s1, s2);
    as = max(s2, as);
  }
  printf("%d", as);
}
