#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5, INF = 1e15;
long long F[maxn][4], A[maxn], N, 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] = F[i - 1][0] + A[i];
    F[i][1] = F[i - 1][1] - A[i];
    F[i][2] = F[i - 1][2] + A[i];
    if (op[i] < 0) {
      F[i][1] = max(F[i][1], F[i - 1][0] + A[i]);
      F[i][2] = max(F[i][2], F[i - 1][1] - A[i]);
    }
    F[i][0] = max(F[i][0], F[i - 1][1] + A[i]);
    F[i][0] = max(F[i][0], F[i - 1][2] + A[i]);
    F[i][1] = max(F[i][1], F[i - 1][2] - A[i]);
  }
  cout << max({F[N][0], F[N][1], F[N][2]}) << '\n';
  return 0;
}
