#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1 << 30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
long long n;
string a[100000 + 5];
long long sum[100000 + 5];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  n += n - 1;
  for (int i = 0; i < (n); i++) cin >> a[i];
  sum[0] = long long(stoi(a[0]));
  for (int i = (1); i < (n); i++) {
    if (i % 2 == 0) continue;
    if (a[i] == "+")
      sum[i + 1] = sum[i - 1] + long long(stoi(a[i + 1]));
    else
      sum[i + 1] = sum[i - 1] - long long(stoi(a[i + 1]));
  }
  long long ans = long long(stoi(a[0]));
  for (int i = (1); i < (n); i++) {
    if (i % 2 == 0) continue;
    if (a[i] == "+")
      ans += long long(stoi(a[i + 1]));
    else
      ans -= long long(stoi(a[i + 1]));
  }
  long long plus = 0;
  long long minus = 0;
  for (int i = (n - 1); i > -1; i--) {
    if (a[i] == "+") continue;
    if (a[i] == "-") {
      ans = max(ans, sum[i - 1] + plus + minus);
      plus += -minus;
      minus = 0LL;
    } else
      minus -= long long(stoi(a[i]));
  }
  cout << ans << endl;
}
