#include <bits/stdc++.h>
using namespace std;
int N;
long long a[200005], s[200005];
int nxt[200005];
long long dp[200005][3];
int main() {
  cin >> N;
  cin >> a[1];
  int N1 = 1;
  char op;
  int x, f = 1;
  for (int i = 1; i < N; i++) {
    cin >> op;
    cin >> x;
    if (op == '-')
      a[++N1] = -x, f = 0;
    else {
      if (f)
        a[N1] += x;
      else
        a[++N1] = x, f = 1;
    }
  }
  N = N1;
  if (N == 1) {
    cout << a[1] << endl;
    return 0;
  }
  for (int i = 1; i <= N; i++) {
    s[i] = s[i - 1] + abs(a[i]);
  }
  memset(dp, 0xf3, sizeof(dp));
  dp[2][0] = dp[2][1] = dp[2][2] = a[1] + a[2];
  for (int i = 3; i <= N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = j; k < 3; k++) {
        if (a[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i]);
        if (a[i] < 0) {
          if (k % 2)
            dp[i][j] = max(dp[i][j], dp[i - 1][k] - a[i]);
          else
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i]);
        }
      }
    }
  }
  cout << dp[N][0];
  return 0;
}
