#include <bits/stdc++.h>
#pragma GCC optimise("ofast")
#pragma GCC optimise("unroll-loops")
using namespace std;
const long long N = 100000 + 10;
const long long MOD = 1000000000 + 7;
const long long INF = 1000000000000000000;
const long long LOG = 25;
vector<long long> nw;
long long n, a[N], dp[N][4];
bool What[N];
long long POW(long long x) { return (x % 2 ? -1 : 1); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (i != n) {
      char c;
      cin >> c;
      if (c == '-') What[i] = 1;
    }
  }
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < 3; j++) dp[i][j] = -INF;
  dp[0][0] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= 1; j++) {
      if (What[i - 1]) {
        dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + POW(j + 1) * a[i]);
        if (j != 0) {
          dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + POW(j + 1) * a[i]);
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][j] + POW(j + 1) * a[i]);
      } else {
        if (j != 0)
          dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + POW(j) * a[i]);
        dp[i][j] = max(dp[i][j], dp[i - 1][j] + POW(j) * a[i]);
      }
    }
  }
  long long ans = max(dp[n][0], max(dp[n][2], dp[n][1]));
  cout << ans;
  return 0;
}
