#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  long long sum;
  scanf("%lld", &sum);
  static int cnt = 0;
  static vector<long long> vec[100010];
  for (int i = 2; i <= N; i++) {
    char c;
    long long x;
    scanf(" %c %lld", &c, &x);
    sum += x;
    if (c == '-') cnt++;
    vec[cnt].push_back(x);
  }
  long long ret = 1000000000000000000;
  long long S = 0;
  for (int i = 1; i <= cnt; i++) {
    if (vec[i].size() == 0) {
      ret = min(ret, S);
      break;
    }
    long long T = S;
    for (int j = 0; j < vec[i].size(); j++) {
      T += vec[i][j];
    }
    ret = min(ret, T);
    S += vec[i][0];
  }
  cout << sum - ret * 2 << endl;
}
