#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> c(n, 1);
  for (long long i = (0); i < ((n)); ++i) {
    char x;
    if (i) cin >> x;
    if (x == '-') c[i] = -1;
    cin >> a[i];
  }
  long long pm[3] = {1, -1, 1};
  vector<vector<long long>> dp(n + 1, vector<long long>(3, -(1LL << 60)));
  dp[0][0] = 0;
  for (long long i = (0); i < ((n)); ++i) {
    for (long long j = (0); j < ((3)); ++j) {
      for (long long k = (0); k < ((j + 1)); ++k) {
        chmax(dp[i + 1][k], dp[i][j] + a[i] * c[i] * pm[j]);
      }
      if (c[i] == -1) chmax(dp[i + 1][j + 1], dp[i][j] + a[i] * c[i] * pm[j]);
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}
