#include <bits/stdc++.h>
using namespace std;
int n, A[100005], B[100005];
long long ans, s[100005], t[100005], now, tot;
int main() {
  scanf("%d", &n);
  scanf("%I64d", &ans);
  t[0] = ans;
  char opt[5];
  for (int i = 1; i < n; i++) {
    scanf("%s%d", opt, &A[i]);
    B[i] = opt[0] == '+' ? 1 : -1;
    ans += A[i] * B[i];
  }
  for (int i = n; i >= 1; i--) s[i] = A[i] + s[i + 1];
  for (int i = 1; i <= n; i++) t[i] = B[i] * A[i] + t[i - 1];
  now = -(1ll << 60);
  tot = 0;
  for (int i = n; i >= 1; i--) {
    tot += A[i];
    if (B[i] == -1) {
      ans = max(ans, t[i - 1] - tot + now);
      now = s[i];
      tot = 0;
    }
  }
  printf("%I64d\n", ans);
}
