#include <bits/stdc++.h>
const int N = 1e6 + 50;
int n, top;
long long S[N], sum;
inline char nc() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int res = 0;
  char ch;
  do ch = nc();
  while (ch < 48 || ch > 57);
  do res = res * 10 + ch - 48, ch = nc();
  while (ch >= 48 && ch <= 57);
  return res;
}
inline int read_operation() {
  char ch;
  do ch = nc();
  while (ch != '+' and ch != '-');
  return ch == '+';
}
int main() {
  n = read();
  S[0] = sum = read();
  top = 0;
  for (int i = 1; i < n; ++i) {
    if (read_operation() == 0) ++top;
    long long t = read();
    S[top] += t, sum += t;
  }
  long long ans = -1e18;
  for (int i = 1; i < top; ++i) ans = std::max(ans, sum - 2 * S[i]);
  if (top == 0) ans = sum;
  printf("%lld", ans);
}
