#include <bits/stdc++.h>
using namespace std;
int n, cnt, a[100005];
long long ans, b[100005], s1[100005], s2[100005];
int main() {
  scanf("%d%lld", &n, &b[cnt = 1]);
  int i, x;
  char ch;
  for (i = 1; i < n; i++) {
    ch = getchar();
    while (ch != '+' && ch != '-') ch = getchar();
    scanf("%d", &x);
    if (ch == '+')
      b[cnt] += x;
    else {
      cnt++;
      a[cnt] = b[cnt] = x;
    }
  }
  for (i = 1; i <= cnt; i++) {
    s1[i] = s1[i - 1] + b[i];
    s2[i] = s2[i - 1] + b[i] - a[i] - a[i];
  }
  for (i = 2; i <= cnt; i++) ans = max(ans, s2[i - 1] - b[i] + s1[cnt] - s1[i]);
  printf("%lld\n", ans);
  return 0;
}
