#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  return getchar();
  static char b[1 << 12], *s = b, *t = b;
  return s == t && (t = (s = b) + fread(b, 1, 1 << 12, stdin), s == t) ? -1
                                                                       : *s++;
}
template <class T>
inline void read(T &x) {
  char b = nc();
  x = 0;
  for (; !isdigit(b); b = nc())
    ;
  for (; isdigit(b); b = nc()) x = x * 10 + b - '0';
}
inline int read() {
  char b = nc();
  for (; b != '-' && b != '+'; b = nc())
    ;
  return b == '-' ? -1 : 1;
}
int n, init;
long long f[2], g[2];
int main() {
  read(n);
  read(init);
  f[1] = -1e9;
  for (int a, op, i = 1; i < n; ++i, swap(f, g)) {
    op = read();
    read(a);
    g[0] = f[0] + a * op;
    g[1] = f[1] - a * op;
    if (op == -1) {
      g[0] = max(g[0], f[1] - a * op);
      g[1] = max(g[1], f[0] + a * op);
    }
  }
  printf("%lld\n", init + max(f[0], f[1]));
  return 0;
}
