#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
long long N;
long long A[111111];
long long sum[111111];
long long dp[111111];
signed main() {
  cin >> N;
  for (long long i = 0; i < (N); i++) {
    char op = '+';
    if (i) cin >> op;
    cin >> A[i];
    if (op == '-') A[i] *= -1;
  }
  for (long long i = 0; i < (N); i++) sum[i + 1] = sum[i] + abs(A[i]);
  long long L = -1001001001001001001ll;
  for (long long i = 0; i < N; i++) {
    dp[i + 1] = dp[i] + A[i];
    chmax(dp[i + 1], sum[i + 1] + L);
    if (A[i] < 0) {
      chmax(L, dp[i] + A[i] - sum[i + 1]);
    }
  }
  cout << dp[N] << endl;
  return 0;
}
