#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n;
long long b[maxn], c[maxn];
struct epoch {
  int op;
  long long ave;
} a[maxn];
int main() {
  scanf("%d", &n);
  char ch[10];
  scanf("%lld", &a[1].ave);
  for (int i = 2; i <= n; ++i) {
    scanf("%s%lld", ch, &a[i].ave);
    if (ch[0] == '-') a[i].op = 1;
  }
  for (int i = 1; i <= n; ++i) b[i] = b[i - 1] + a[i].ave;
  int las = 0;
  for (int i = 1; i <= n; ++i)
    c[i] = c[i - 1] + ((a[i].op) ? -a[i].ave : a[i].ave);
  long long ans = c[n];
  for (int i = 1; i <= n; ++i)
    if (a[i].op) {
      if (!las) {
        las = i;
        continue;
      }
      ans = max(ans, c[las] - (c[i - 1] - c[las]) + b[n] - b[i - 1]);
    }
  printf("%lld", ans);
  return 0;
}
