#include <bits/stdc++.h>
using namespace std;
int n;
int val[100005], func[100005], nex[100005];
long long sum[100005];
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
int main() {
  read(n);
  read(val[1]), func[1] = 1;
  for (int i = 2; i <= n; ++i) {
    func[i] = (getchar() == '+' ? 1 : -1);
    read(val[i]);
  }
  nex[n] = n + 1;
  for (int i = n; i > 1; --i) {
    sum[i] = val[i] + sum[i + 1];
    nex[i - 1] = (func[i] == -1 ? i : nex[i]);
  }
  long long ans, cur, res;
  cur = val[1];
  for (int i = 2; i <= n; ++i) {
    if (func[i] == -1) {
      res = cur - (sum[i] - sum[nex[i]]) + sum[nex[i]];
      if (res > ans) ans = res;
    }
    cur += func[i] * val[i];
  }
  if (cur > ans) ans = cur;
  cout << ans << endl;
  return 0;
}
