#include <bits/stdc++.h>
using namespace std;
long long n;
long long st;
long long dp[3];
int main() {
  cin >> n >> st;
  dp[0] = st;
  dp[1] = -9e18;
  dp[2] = -9e18;
  for (long long i = (long long)(0); i < (long long)(n - 1); i++) {
    char c;
    long long a;
    cin >> c >> a;
    long long nxt[3];
    nxt[0] = nxt[1] = nxt[2] = -9e18;
    if (c == '+') {
      nxt[0] = (nxt[0] > dp[0] + a ? nxt[0] : dp[0] + a);
      nxt[1] = (nxt[1] > dp[1] - a ? nxt[1] : dp[1] - a);
      nxt[0] = (nxt[0] > dp[1] + a ? nxt[0] : dp[1] + a);
      nxt[2] = (nxt[2] > dp[2] + a ? nxt[2] : dp[2] + a);
      nxt[1] = (nxt[1] > dp[2] - a ? nxt[1] : dp[2] - a);
      nxt[0] = (nxt[0] > dp[2] + a ? nxt[0] : dp[2] + a);
    } else {
      nxt[0] = (nxt[0] > dp[0] - a ? nxt[0] : dp[0] - a);
      nxt[1] = (nxt[1] > dp[0] - a ? nxt[1] : dp[0] - a);
      nxt[1] = (nxt[1] > dp[1] + a ? nxt[1] : dp[1] + a);
      nxt[0] = (nxt[0] > dp[1] - a ? nxt[0] : dp[1] - a);
      nxt[2] = (nxt[2] > dp[1] + a ? nxt[2] : dp[1] + a);
      nxt[2] = (nxt[2] > dp[2] - a ? nxt[2] : dp[2] - a);
      nxt[1] = (nxt[1] > dp[2] + a ? nxt[1] : dp[2] + a);
      nxt[0] = (nxt[0] > dp[2] - a ? nxt[0] : dp[2] - a);
    }
    dp[0] = nxt[0];
    dp[1] = nxt[1];
    dp[2] = nxt[2];
  }
  cout << *max_element(dp, dp + 3) << endl;
  return 0;
}
