#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const long long INF = 100000000;
const long long MOD = 1000000007;
int n;
long long a[100000];
char c[100000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    if (i == 0)
      cin >> a[i];
    else
      cin >> c[i - 1] >> a[i];
  }
  long long ans = 0;
  long long sum = 0;
  long long mcnt = INF * INF;
  long long pm = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  for (int i = 0; i < n - 1; i++) {
    if (c[i] == '+') {
      mcnt += a[i + 1];
    } else {
      ans = max(ans, sum - mcnt * 2);
      mcnt = a[i + 1];
      sum -= pm * 2;
      pm = a[i + 1];
    }
  }
  cout << max(ans, sum - mcnt * 2) << endl;
}
