#include <bits/stdc++.h>
using namespace std;
struct _IO {
  _IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
} _io;
void uni(vector<int> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
long double rd() {
  long double x;
  cin >> x;
  return x;
}
long long ri() {
  long long x;
  cin >> x;
  return x;
}
string rs() {
  string s;
  cin >> s;
  return s;
}
pair<int, int> rpi() {
  pair<int, int> x;
  cin >> x.first >> x.second;
  return x;
}
vector<int> rvi(int n, int f = 0) {
  vector<int> v(n + f);
  for (int i = f; i < v.size(); i++) cin >> v[i];
  return v;
}
void pr(){};
template <class T, class... U>
void pr(T x, U... y) {
  cout << x << ' ', pr(y...);
}
void prl() { cout << '\n'; };
template <class T, class... U>
void prl(T x, U... y) {
  cout << x << ' ', prl(y...);
}
void pr(const vector<int> &v, int f = 0) {
  for (int i = f; i < v.size(); i++) cout << v[i] << ' ';
}
void prl(const vector<int> &v, int f = 0) {
  pr(v, f);
  cout << '\n';
}
void kk() { cerr << endl; };
template <class T, class... U>
void kk(T x, U... y) {
  cerr << x << ' ', prl(y...);
}
const int N = 3e5 + 5, M = 1e9 + 7;
int main() {
  int n = ri(), lst = 0;
  vector<int> a;
  for (int i = (0); i < (n); ++i) {
    int flg = 1;
    if (i) flg = rs() == "+";
    int x = ri();
    if (flg)
      lst += x;
    else
      a.push_back(lst), a.push_back(-x), lst = 0;
  }
  if (lst) a.push_back(lst);
  vector<long long> b(a.size() + 1);
  for (int i = (0); i < (a.size()); ++i) {
    b[i + 1] = b[i] + a[i];
  }
  long long ans = b[a.size()], sum = abs(a.back());
  for (int i = (a.size() - 1); i >= (1); --i) {
    if (a[i - 1] > 0)
      sum += a[i - 1];
    else {
      if (a[i] > 0)
        ans = max(ans, sum - 2 * a[i] + a[i - 1] + b[i - 1]);
      else
        ans = max(ans, sum + a[i - 1] + b[i - 1]);
      sum -= a[i - 1];
    }
  }
  prl(ans);
}
