#include <bits/stdc++.h>
const int N = 1e6 + 50;
int n, top;
long long S[N], sum[N];
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[0] = read();
  top = 0;
  for (int i = 1; i < n; ++i) {
    int p = read_operation();
    long long t = read();
    if (p == 1)
      sum[top] += t, S[top] += t;
    else {
      ++top;
      S[top] = S[top - 1] + t;
      sum[top] = sum[top - 1] - t;
    }
  }
  long long ans = -1e18;
  for (int i = 0; i < top; ++i)
    ans = std::max(ans, sum[i] - (S[i + 1] - S[i]) + (S[top] - S[i + 1]));
  printf("%lld", ans);
}
