#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long F[maxn][4];
long long A[maxn], N;
long long op[maxn];
long long main() {
  scanf("%lld", &N);
  for (long long i = 1; i <= N; i++) {
    long long bj = 1, x;
    if (i > 1) {
      char buf[10];
      scanf("%s", buf);
      bj = buf[0] == '+' ? +1 : -1;
    }
    scanf("%lld", &x);
    A[i] = bj * x;
    op[i] = bj;
  }
  F[0][1] = -INF;
  F[0][2] = -INF;
  for (long long i = 1; i <= N; i++) {
    F[i][0] = max({F[i - 1][0] + A[i], F[i - 1][1] + A[i], F[i - 1][2] + A[i]});
    F[i][1] = max({op[i] < 0 ? F[i - 1][0] + A[i] : -INF, F[i - 1][1] - A[i],
                   F[i - 1][2] - A[i]});
    F[i][2] = max({op[i] < 0 ? F[i - 1][1] - A[i] : -INF, F[i - 1][2] + A[i]});
  }
  cout << max({F[N][0], F[N][1], F[N][2]}) << '\n';
  return 0;
}
