#include <bits/stdc++.h>
using namespace std;
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;
template <typename T>
inline void read(T &x) {
  char ch, t = 0;
  x = 0;
  while (!isdigit(ch = (iS == iT
                            ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)))
    t |= ch == '-';
  while (isdigit(ch))
    x = x * 10 + (ch ^ 48),
    ch = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
  x = t ? -x : x;
}
inline int read_int() {
  int x;
  return read(x), x;
}
inline long long read_ll() {
  long long x;
  return read(x), x;
}
template <typename T>
inline void chkmin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void chkmax(T &a, T b) {
  a = a > b ? a : b;
}
long long f[2][3];
int main() {
  int n = read_int(), x = read_int(), o = 0, t = 1;
  f[0][0] = x, f[0][1] = -1e18, f[0][2] = -1e18;
  for (int i = 1; i < n; i++) {
    char opt = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                            (iS == iT ? EOF : *iS++))
                         : *iS++);
    while (opt != '-' && opt != '+')
      opt = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                      : *iS++);
    x = read_int();
    if (opt == '+') {
      f[t][0] = max(f[o][0], max(f[o][1], f[o][2])) + x;
      f[t][1] = max(f[o][1], f[o][2]) - x;
      f[t][2] = f[o][2] + x;
    } else {
      f[t][0] = max(f[o][0] - x, max(f[o][1], f[o][2]) + x);
      f[t][1] = max(f[o][0] - x, max(f[o][1], f[o][2]) + x);
      f[t][2] = f[o][1] + x;
    }
    o ^= 1, t ^= 1;
  }
  cout << max(max(f[o][0], f[o][1]), f[o][2]) << endl;
  return 0;
}
