#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int inf = 0x3f3f3f3f;
int op[maxn];
int a[maxn];
int qzhh[maxn];
int yuan[maxn];
int lstt[maxn];
char s[3];
int n;
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  qzhh[1] = yuan[1] = a[1];
  op[1] = 1;
  int ans = 0;
  for (int i = 2; i <= n; ++i) {
    scanf("%s%d", s, &a[i]);
    op[i] = (s[0] == '+');
    qzhh[i] = qzhh[i - 1] + a[i];
    yuan[i] = yuan[i - 1] + (op[i] ? a[i] : -a[i]);
  }
  op[n + 1] = op[n + 2] = 0;
  qzhh[n + 1] = qzhh[n + 2] = qzhh[n];
  yuan[n + 1] = yuan[n + 2] = yuan[n];
  n += 2;
  int lst = n + 1;
  for (int i = n; i; --i) {
    if (!op[i]) {
      lstt[i] = lst;
      lst = i;
    }
  }
  for (int i = lst; lstt[i] <= n; i = lstt[i]) {
    int l = i, r = lstt[i];
    ans = max(
        ans, yuan[l - 1] - (qzhh[r - 1] - qzhh[l - 1]) + qzhh[n] - qzhh[r - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
