#include <bits/stdc++.h>
const int inf = 1039074182;
using namespace std;
int n;
int a[100005];
vector<long long> vec;
vector<int> pos;
vector<bool> b;
long long sumabs[100005];
int main() {
  cin >> n;
  char x;
  cin >> a[0];
  long long res = a[0];
  for (int i = 1; i < n; i++) {
    while (x != '+' && x != '-') x = getchar();
    scanf("%d", a + i);
    if (x == '-') a[i] = -a[i];
    x = getchar();
    res += a[i];
  }
  for (int i = 0; i < n;) {
    long long sum = 0;
    while (a[i] > 0 && i < n) {
      sum += a[i];
      i++;
    }
    vec.push_back(sum);
    while (a[i] < 0 && i < n) {
      vec.push_back(a[i]);
      i++;
    }
  }
  while (vec.back() == 0) vec.pop_back();
  n = vec.size();
  memset(a, 0, sizeof(a));
  memset(sumabs, 0, sizeof(sumabs));
  for (int i = 0; i < n; i++) {
    a[i] = vec[i];
  }
  sumabs[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    sumabs[i] = sumabs[i + 1] + abs(a[i]);
  }
  long long now = 0;
  for (int i = 0; i < n; i++) {
    now += a[i];
    if (a[i] < 0) {
      res = max(res, now - a[i + 1] + sumabs[i + 2]);
    }
  }
  cout << res << endl;
  return 0;
}
