#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  int f = 1;
  char k = getchar();
  x = 0;
  for (; k > '9' || k < '0'; k = getchar())
    if (k == '-') f = -1;
  for (; k >= '0' && k <= '9'; k = getchar()) x = (x << 3) + (x << 1) + k - '0';
  x *= f;
}
template <class T>
inline void _print(T x) {
  if (x / 10) _print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  _print(x);
}
long long mul(long long a, long long b, long long mod) {
  long double c = 1.;
  return (a * b - (long long)(c * a * b / mod) * mod) % mod;
}
inline int qpow(int x, int m, int mod) {
  int res = 1, bas = x;
  while (m) {
    if (m & 1) res = (1ll * res * bas) % mod;
    bas = (1ll * bas * bas) % mod, m >>= 1;
  }
  return res;
}
const int N = 1e5 + 5;
int n, val[N], ty[N];
long long ans, abs_sum[N], sum[N];
char op[2];
vector<int> vec;
int main() {
  read(n), read(val[1]), sum[1] = val[1];
  for (register int i = 2; i <= n; ++i) {
    scanf("%s", op), read(val[i]);
    if (op[0] == '-')
      vec.push_back(i), sum[i] = sum[i - 1] - val[i];
    else
      sum[i] = sum[i - 1] + val[i];
  }
  vec.push_back(n + 1);
  for (register int i = 1; i <= n; ++i) abs_sum[i] = abs_sum[i - 1] + val[i];
  ans = INT_MIN;
  for (register int i = 0; i < (int)vec.size() - 1; ++i) {
    int x = vec[i], y = vec[i + 1];
    ans = max(ans, sum[x - 1] - (abs_sum[y - 1] - abs_sum[x - 1]) +
                       (abs_sum[n] - abs_sum[y - 1]));
  }
  print(ans);
  return 0;
}
