#include <bits/stdc++.h>
using namespace std;
long long val[100005];
long long suf[100005];
int n;
int main() {
  scanf("%d", &n);
  scanf("%lld", &val[1]);
  int cnt = 1;
  for (int i = 2, t; i <= n; i++) {
    char ch = getchar();
    while (ch != '+' && ch != '-') ch = getchar();
    scanf("%d", &t);
    if (ch == '+')
      val[cnt] += t;
    else
      val[++cnt] = t;
  }
  for (int i = cnt; i >= 1; i--) suf[i] = suf[i + 1] + val[i];
  long long pre = val[1], ans = -1e18;
  for (int i = 2; i <= cnt; i++) {
    pre -= val[i];
    ans = max(ans, pre + suf[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
