#include <bits/stdc++.h>
using namespace std;
long dp[3], a;
char op;
int n;
int main() {
  cin >> n >> dp[0];
  dp[1] = -1e18;
  for (int i = 1; i < n; i++) {
    cin >> op >> a;
    if (op == '+') {
      dp[0] += a;
      dp[1] = max(dp[1] - a, dp[2] += a);
    } else {
      dp[0] = dp[1] = max(dp[2] = dp[1] + a, dp[0] - a);
    }
  }
  cout << dp[0] << endl;
}
