#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
template <typename T1, typename T2>
inline T1 gmax(T1 &a, T2 b) {
  return a = a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 gmin(T1 &a, T2 b) {
  return a = a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
inline int tc() {
  int c = fetch();
  while (c <= 32 && c != EOF) c = fetch();
  return c;
}
}  // namespace ae86
using ae86::tc;
using ae86::ty;
const int _ = 100007;
const long long linf = 0x3f3f3f3f3f3f3f3f;
int n, dir[_] = {0};
long long val[_] = {0};
long long f[_][3];
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), dir[1] = 1, val[1] = ty();
  for (int i = 2; i <= n; i++) dir[i] = tc() == '+', val[i] = ty();
  n += 2;
  memset(f, -64, sizeof(f));
  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    if (dir[i + 1]) {
      gmax(f[i + 1][0], f[i][0] + val[i + 1]);
      gmax(f[i + 1][1], f[i][1] - val[i + 1]);
      gmax(f[i + 1][2], f[i][2] + val[i + 1]);
      gmax(f[i + 1][0], f[i][1] + val[i + 1]);
      gmax(f[i + 1][1], f[i][2] - val[i + 1]);
    } else {
      gmax(f[i + 1][0], f[i][0] - val[i + 1]);
      gmax(f[i + 1][1], f[i][1] + val[i + 1]);
      gmax(f[i + 1][2], f[i][2] - val[i + 1]);
      gmax(f[i + 1][1], f[i][0] - val[i + 1]);
      gmax(f[i + 1][2], f[i][1] + val[i + 1]);
      gmax(f[i + 1][0], f[i][1] - val[i + 1]);
      gmax(f[i + 1][1], f[i][2] + val[i + 1]);
    }
  }
  cout << f[n][0] << lf;
  return 0;
}
