#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const long long inf = 1e15;
const long long llf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n, x;
long long dp[3][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> x;
  dp[0][1] = x;
  dp[1][1] = dp[2][1] = -inf;
  for (int i = 2; i <= n; i++) {
    char c;
    cin >> c >> x;
    if (c == '+') {
      dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]) + x;
      dp[1][i] = dp[1][i - 1] - x;
      dp[2][i] = dp[2][i - 1] + x;
    } else {
      dp[0][i] = dp[0][i - 1] - x;
      dp[1][i] = max({dp[0][i - 1] - x, dp[1][i - 1] + x, dp[2][i - 1] + x});
      dp[2][i] = max(dp[1][i - 1] + x, dp[2][i - 1] - x);
    }
  }
  cout << max({dp[0][n], dp[1][n], dp[2][n]});
  return 0;
}
