#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int total[N], x[N], s[N];
char op[N][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    if (i != 1) scanf("%s", op[i]);
    scanf("%d", &x[i]);
    if (i == 1 || op[i][0] == '+')
      total[i] = total[i - 1] + x[i];
    else
      total[i] = total[i - 1] - x[i];
  }
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + x[i];
  int p = 2, ans = 0;
  for (; p <= n;) {
    if (op[p][0] == '-') {
      int lst = p - 1, sum = x[p];
      p++;
      while (op[p][0] == '+' && p <= n) sum += x[p], p++;
      p--;
      ans = max(s[n] - 2 * sum - s[lst] + total[lst], ans);
    }
    p++;
  }
  cout << ans << endl;
  return 0;
}
