#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], hz[100005];
char s[100005];
long long max(long long x, long long y) { return x > y ? x : y; }
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; ++i) {
    scanf("%lld", &a[i]);
    scanf(" %c", &s[i]);
  }
  scanf("%lld", &a[n]);
  s[0] = '+';
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    if (s[i - 1] == '+')
      ans += a[i];
    else
      ans -= a[i];
  }
  hz[n] = a[n];
  for (long long i = n - 1; i >= 1; --i) hz[i] = hz[i + 1] + a[i];
  long long now = 0;
  for (long long i = 1; i <= n; ++i) {
    if (s[i - 1] == '+') now += a[i];
    if (s[i - 1] == '-') {
      now -= a[i];
      long long hh = now;
      long long j = i;
      while (j < n && s[j] != '-') {
        hh -= a[j + 1];
        j++;
      }
      if (j >= n) break;
      hh += hz[j + 1];
      ans = max(ans, hh);
      now -= a[i];
    }
  }
  cout << ans << endl;
}
