#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int main() {
  int n;
  cin >> n;
  char sgn;
  char hj;
  int x;
  long long ans = 0;
  while ((sgn != '-') && (cin >> x >> sgn)) {
    ans += x;
  }
  cin >> x;
  if (sgn != '-') {
    ans += x;
    cout << ans;
    return 0;
  }
  ans -= x;
  long long sm = 0;
  while (cin >> sgn >> x) {
    if (sgn == '+')
      sm += x;
    else {
      sm -= x;
      ans += max(sm, -sm);
      sm = 0;
    }
  }
  ans += sm;
  cout << ans;
  return 0;
}
