#include <bits/stdc++.h>
using namespace std;
int a[100010];
long long pre[100010], suf[100010];
char c[100010];
int main() {
  ios::sync_with_stdio(false);
  int n;
  long long ans = 0;
  cin >> n >> a[1];
  pre[1] = a[1];
  for (register int i = 2; i <= n; i++) cin >> c[i] >> a[i];
  for (register int i = 2; i <= n; i++)
    pre[i] = (c[i] == '-') ? pre[i - 1] - a[i] : pre[i - 1] + a[i];
  for (register int i = n; i >= 1; i--) suf[i] = suf[i + 1] + a[i];
  for (register int i = 1, j; i <= n; i++)
    if (c[i] == '-') {
      long long sum = a[i];
      for (j = i + 1; j <= n && c[j] == '+'; j++) sum += a[j];
      ans = max(ans, pre[i - 1] + suf[j] - sum);
    }
  cout << ans;
  return 0;
}
