#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
int a[N];
long long b[N];
int main() {
  int n = gi() - 1, i, m = 0;
  char c;
  long long sum = gi(), ans = -1LL << 60;
  for (i = 1; i <= n; i++) {
    while ((c = getchar()) != '+' && c != '-')
      ;
    if (c == '+')
      sum += b[m] = gi();
    else
      sum += a[++m] = gi();
  }
  for (i = 1; i <= m; i++) {
    ans = max(ans, sum - (a[i] + b[i]) * 2);
    sum -= a[i] * 2;
  }
  cout << max(ans, sum) << endl;
  return 0;
}
