#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
long long dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
long long dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long N;
long long A[110000];
char op[110000];
signed main() {
  cin >> N;
  cin >> A[0];
  for (long long i = 1; i < N; i++) cin >> op[i] >> A[i];
  op[N] = '-';
  A[N] = 0;
  long long sum = A[0], total_minus = 0, cur_minus = 0, min_dec = LLONG_MAX;
  for (long long i = 1; i <= N; i++) {
    if (op[i] == '+') {
      if (total_minus > 0) cur_minus += A[i];
    } else {
      if (total_minus > 0) min_dec = min(min_dec, total_minus + cur_minus);
      total_minus += A[i];
      cur_minus = 0;
    }
    sum += A[i];
  }
  cout << sum - 2 * min_dec;
}
