#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <class T, class U>
inline void chmax(T& a, U const& b) {
  a = max<T>(a, b);
}
ll solve(int n, vector<int> const& a, vector<char> const& op) {
  vector<ll> cur(n, LLONG_MIN), prv;
  cur[0] = a[0];
  for (int i = (1); (i) < (int)(n); ++(i)) {
    cur.swap(prv);
    cur.assign(n, LLONG_MIN);
    auto sign = [&](int j) { return (j % 2 == 0 ? +1 : -1); };
    if (op[i - 1] == '+') {
      for (int j = 0; (j) < (int)(n); ++(j)) {
        if (prv[j] != LLONG_MIN) {
          chmax(cur[j], prv[j] + sign(j) * a[i]);
        }
        if (j + 1 < n and prv[j + 1] != LLONG_MIN) {
          chmax(cur[j], prv[j + 1] + sign(j) * a[i]);
        }
      }
    } else if (op[i - 1] == '-') {
      for (int j = 0; (j) < (int)(n); ++(j)) {
        if (j >= 1 and prv[j] != LLONG_MIN) {
          chmax(cur[j], prv[j] + sign(j) * a[i]);
        }
        if (j - 1 >= 0 and prv[j - 1] != LLONG_MIN) {
          chmax(cur[j], prv[j - 1] + sign(j) * a[i]);
        }
      }
    } else {
      assert(false);
    }
  }
  return *max_element(begin(cur), end(cur));
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<char> op(n - 1);
  for (int i = 0; (i) < (int)(n - 1); ++(i)) {
    cin >> a[i] >> op[i];
  }
  cin >> a[n - 1];
  cout << solve(n, a, op) << endl;
  return 0;
}
