#include <bits/stdc++.h>
const long long N = 1e5 + 5, INF = 1e18;
using namespace std;
long long n, dp[N][3], arr[N];
char c[N];
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 3; j++) {
      dp[i][j] = -INF;
    }
    long long mult = 1;
    if (i) {
      cin >> c[i];
      if (c[i] == '-') mult = -1;
    }
    cin >> arr[i];
    arr[i] *= mult;
  }
  dp[0][0] = arr[0];
  for (long long i = 1; i < n; i++) {
    dp[i][0] = dp[i - 1][0] + arr[i];
    dp[i][0] = max(dp[i][0], dp[i - 1][1] + arr[i]);
    dp[i][0] = max(dp[i][0], dp[i - 1][2] + arr[i]);
    dp[i][1] = dp[i - 1][1] - arr[i];
    if (c[i] == '-') dp[i][1] = max(dp[i][1], dp[i - 1][0] + arr[i]);
    dp[i][1] = max(dp[i][1], dp[i - 1][2] - arr[i]);
    dp[i][2] = dp[i - 1][2] + arr[i];
    if (c[i] == '-') dp[i][2] = max(dp[i][2], dp[i - 1][1] - arr[i]);
  }
  long long ans = max(dp[n - 1][0], dp[n - 1][1]);
  ans = max(ans, dp[n - 1][2]);
  cout << ans;
}
