#include <bits/stdc++.h>
using namespace std;
int n;
int a[120000];
char c[120000];
const long long INF = 1e18;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    if (i != n - 1) scanf(" %c", c + i + 1);
  }
  c[0] = '+';
  long long mn = INF;
  long long sum = 0;
  long long cur = 0;
  long long now = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    if (c[i] == '+') {
      cur += a[i];
    } else {
      if (now != 0) mn = min(mn, now + cur);
      cur = 0;
      now += a[i];
    }
  }
  cout << sum - 2 * mn << "\n";
  return 0;
}
