#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int SIZE = 1e6 + 5;
const long long INF = 1LL << 58;
const double eps = 1e-13;
int v[100009];
bool o[100009];
long long l[100009];
long long r[100009];
int main() {
  int(n);
  scanf("%d", &n);
  scanf("%d", &(v[0]));
  for (int i = (1); i < (n); ++i) {
    char c;
    scanf(" %c", &c);
    o[i] = (c == '+');
    scanf("%d", &(v[i]));
  }
  long long sum = 0;
  for (int i = 0; i < (n); ++i) {
    sum += v[i];
  }
  for (int i = (1); i < (n); ++i) {
    if (!o[i]) {
      l[i] = l[i - 1] + v[i] * 2;
    } else
      l[i] = l[i - 1];
  }
  for (int i = (1); i < (n); ++i) {
    if (!o[i]) {
      r[i] = 2 * v[i];
      for (int j = i + 1; j < n; j++) {
        if (!o[j]) break;
        r[i] += 2 * v[j];
      }
    }
  }
  long long cmax = -INF;
  for (int i = (1); i < (n); ++i) {
    if (!o[i]) {
      cmax = max(cmax, sum - l[i - 1] - r[i]);
    }
  }
  printf("%lld", cmax);
}
