#include <bits/stdc++.h>
using namespace std;
int n, a[100100];
bool op[100100];
void sread() {
  scanf("%d", &n);
  char s[10];
  for (int i = 0, __yuki = n - 1; i < __yuki; ++i) {
    scanf("%d%s", a + i, s);
    op[i + 1] = s[0] == '-';
  }
  scanf("%d", a + n - 1);
}
int main(int argc, char **argv) {
  sread();
  long long maxs = 0, mins = 0, curs = 0, t;
  for (int i = n - 1, __yui = 1; i >= __yui; --i)
    if (op[i]) {
      t = maxs;
      maxs = max(-a[i] + curs + maxs, -(a[i] + curs + mins));
      mins = min(-(a[i] + curs) + mins, -(a[i] + curs + t));
      curs = 0;
    } else
      curs += a[i];
  printf("%lld\n", maxs + a[0]);
  return 0;
}
