#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 100010;
long long A[Maxn];
char ch[Maxn];
long long N;
long long Sum[Maxn];
long long Add[Maxn];
int main() {
  scanf("%lld", &N);
  scanf("%lld", &A[0]);
  ch[0] = '+';
  for (long long i = 1; i < N; i++) {
    char c = getchar();
    while (c != '+' && c != '-') c = getchar();
    ch[i] = c;
    scanf("%lld", &A[i]);
  }
  for (long long i = 0; i < N; i++) Add[i] = Add[i - 1] + A[i];
  for (long long i = 0; i < N; i++)
    Sum[i] = Sum[i - 1] + A[i] * ((ch[i] == '+') ? 1 : -1);
  long long nx = N;
  long long ans = LLONG_MIN;
  for (long long i = N - 1; i >= 0; i--)
    if (ch[i] == '-') {
      if (nx == N)
        ans = max(ans, Sum[i - 1] - A[i] + Add[i + 1]);
      else
        ans = max(ans, Sum[i - 1] - (Add[nx - 1] - Add[i - 1]) +
                           (Add[N - 1] - Add[nx - 1]));
      nx = i;
    }
  if (nx == N) ans = max(ans, Sum[N - 1]);
  return printf("%lld\n", ans), 0;
}
