#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], b[100005], sum[100005];
long long f[100005][2];
signed main() {
  scanf("%lld", &n);
  b[1] = 1;
  scanf("%lld", &a[1]);
  for (long long i = 2; i <= n; i++) {
    char c;
    scanf(" %c %lld", &c, &a[i]);
    if (c == '-')
      b[i] = -1;
    else
      b[i] = 1;
  }
  for (long long i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i];
  memset(f, 0xcf, sizeof(f));
  f[0][0] = 0;
  long long ans = -(1LL << 60);
  for (long long i = 1; i <= n; i++) {
    f[i][0] = max(f[i - 1][0], f[i - 1][1]) + a[i] * b[i];
    f[i][1] = f[i - 1][1] + a[i] * b[i] * (-1);
    if (b[i] == -1) {
      f[i][1] = max(f[i][1], f[i - 1][0] + a[i] * b[i]);
      ans = max(ans, f[i - 1][1] - a[i] * b[i] + sum[i + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}
