#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9 + 7;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<pair<long long, long long> > vii;
typedef vector<vii> vvii;
typedef vector<bool> vb;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<char> op;
  vi num;
  long long x;
  cin >> x, num.push_back(x);
  for (long long i = 0; i < n - 1; i++) {
    char ch;
    cin >> ch >> x;
    op.push_back(ch), num.push_back(x);
  }
  vvi dp(n, vector<long long>(3));
  dp[0][0] = num[0];
  dp[0][1] = -INF;
  dp[0][2] = -INF;
  for (long long i = 1; i < n; i++) {
    if (op[i - 1] == '+') {
      dp[i][1] = dp[i - 1][1] - num[i];
      dp[i][2] = dp[i - 1][2] + num[i];
      dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + num[i];
    } else {
      dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - num[i];
      dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + num[i];
      dp[i][0] = -INF;
    }
  }
  long long a[] = {dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]};
  sort(a, a + 3);
  cout << a[2] << endl;
  return 0;
}
