#include <bits/stdc++.h>
int MOD = 1e9 + 7;
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
int main() {
  int n;
  cin >> n;
  int a[110000];
  cin >> a[0];
  for (int i = 1; i <= n - 1; ++i) {
    char c;
    cin >> c;
    cin >> a[i];
    if (c == '-') a[i] *= -1;
  }
  long long sum = 0, pos = 0;
  vector<long long> v;
  while (pos < n) {
    while (a[pos] > 0 && pos < n) {
      sum += a[pos];
      pos++;
    }
    v.push_back(sum);
    if (pos < n) v.push_back(a[pos]);
    sum = 0;
    pos++;
  }
  long long m = 1e18, temp = 0;
  pos = 1;
  while (pos * 2 <= v.size()) {
    temp -= v[pos * 2 - 1];
    m = min(m, temp + v[pos * 2]);
    pos++;
  }
  for (int i = 0; i < n; i++) {
    sum += abs(a[i]);
  }
  cout << sum - 2 * m;
  return 0;
}
