#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(long long x) {
  stringstream second;
  second << x;
  return second.str();
}
long long stl(string x) {
  stringstream second(x);
  long long temp;
  second >> temp;
  return temp;
}
string cts(char x) {
  string second(1, x);
  return second;
}
const int MOD = 1e9 + 7;
template <typename T>
void maxself(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void minself(T& a, T b) {
  a = min(a, b);
}
int A[(int)1e5 + 5], dp[(int)1e5 + 5][3];
char op[(int)1e5 + 5];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -127, sizeof dp);
  int n;
  cin >> n;
  cin >> A[1];
  for (long long i = (2); i <= (long long)(n); ++i) {
    cin >> op[i] >> A[i];
  }
  dp[1][0] = A[1];
  for (long long i = (2); i <= (long long)(n); ++i) {
    if (op[i] == '-') A[i] *= -1;
    maxself(dp[i][0], dp[i - 1][0] + A[i]);
    maxself(dp[i][1], dp[i - 1][1] - A[i]);
    maxself(dp[i][2], dp[i - 1][2] + A[i]);
    if (op[i] == '-') {
      maxself(dp[i][1], dp[i - 1][0] + A[i]);
      maxself(dp[i][2], dp[i - 1][1] - A[i]);
    }
    maxself(dp[i][1], dp[i - 1][2] + A[i]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]});
}
