#include <bits/stdc++.h>
using namespace std;
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}
long long mainmain() {
  int n;
  cin >> n;
  long long ans1;
  cin >> ans1;
  if (n == 1) {
    return ans1;
  }
  vector<int> op(n - 1);
  vector<long long> v(n - 1);
  vector<int> minus;
  for (int(i) = (0); (i) < ((n - 1)); ++(i)) {
    char t;
    cin >> t;
    cin >> v[i];
    if (t == '-') {
      minus.push_back(i);
      op[i] = -1;
    } else {
      op[i] = 1;
    }
  }
  vector<long long> suf(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    suf[i] = v[i];
    if (i < n - 2) suf[i] += suf[i + 1];
  }
  long long ans2 = -0x3f3f3f3f3f3f3f3fLL;
  long long tval = ans1;
  int p = 0;
  for (int(i) = (0); (i) < ((minus.size() - 1)); ++(i)) {
    int l = minus[i];
    int r = minus[i + 1];
    while (p < l) tval += op[p] * v[p], p++;
    long long tmp = suf[l] - suf[r];
    tmp *= -1;
    tmp += tval;
    tmp += suf[r];
    ans2 = max(ans2, tmp);
  }
  return ans2;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  cout << mainmain() << endl;
}
