#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9;
long long MOD = 1e9 + 7;
long long ans;
char c;
long long N, a, t, out;
vector<pair<long long, long long> > V;
int main() {
  cin >> N;
  cin >> ans;
  for (int i = 1; i < N; ++i) {
    cin >> c >> a;
    if ((long long)V.size() == 0 && c == '+') {
      ans += a;
      continue;
    }
    ans += a;
    if ((long long)V.size() && V.back().first && c == '+') {
      V.back().second += a;
      continue;
    }
  }
  if (V[1].first == 0) {
    cout << ans;
    return 0;
  }
  out = max(out, ans - 2 * V[1].second);
  cout << out;
}
