#include <bits/stdc++.h>
using namespace std;
int N;
int A[100000];
bool sign[100000];
long long dp[100000][3];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < (N); i++) {
    if (i > 0) {
      char c;
      cin >> c;
      sign[i] = c == '-';
    }
    cin >> A[i];
  }
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (3); j++) dp[i][j] = -(1LL << 60);
  }
  dp[0][0] = 0;
  for (int i = 0; i < (N); i++) {
    for (int d = 0; d < (3); d++) {
      if (dp[i][d] == -(1LL << 60)) continue;
      int nd = d;
      if (sign[i]) {
        nd++;
        if (nd == 3) nd = 1;
      }
      int b = (nd % 2 == 0) ? 1 : -1;
      dp[i + 1][nd] = max(dp[i + 1][nd], dp[i][d] + 1LL * b * A[i]);
    }
    dp[i + 1][1] = max(dp[i + 1][1], dp[i + 1][2]);
    dp[i + 1][0] = max(dp[i + 1][0], dp[i + 1][1]);
  }
  cout << dp[N][0] << "\n";
  return 0;
}
